SQL Field to include HTML with Fields, I am trying to include an HTML page in a Database field that includes |
SQL Field to include HTML with Fields, I am trying to include an HTML page in a Database field that includes |
WhiskeyDevil |
Oct 16 2007, 04:28 PM
Post
#1
|
Group: Members Posts: 3 Joined: 16-October 07 Member No.: 4,073 |
I have an database that includes an html field that is sent to a pc to be displayed. The html needs to use other fields that are included in the record it is associated with. Since there are possibly hundreds of different ways this html would need to be created to include the fields I am looking for something that could be put into each record that would pull the corresponding information. It would also allow me to change the look and feel if needed after the fact.
Here is an example. Field Data Color Red Size Large Type Dumpster HTML output to screen This is the large Red dumpster. One last thing. The displays will show one of the records but I will have many different screens showing different records throughout the location. Any help is appreciated. |
Brian Chandler |
Oct 16 2007, 08:00 PM
Post
#2
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
Well, it's not possible to just "have a database" and just "send it to a pc". You have to write a program (e.g. in perl or PHP) that accesses the database using the database calls (e.g. the mysql functions in the php library) and generates the required html text in a particular case. Do you have something like this?
If for each combination of data you need an arbitrarily different description (i.e. if you can't generate them automatically) then you need to save each one in a (possibly separate) db table. Without seeing what you actually have at the moment, it's hard to know where to start. |
WhiskeyDevil |
Oct 16 2007, 08:47 PM
Post
#3
|
Group: Members Posts: 3 Joined: 16-October 07 Member No.: 4,073 |
Brian,
Sorry for not communicating the problem clearly. The program I have looks at the database to find the correct record. It then looks that the HTML field and displays it on a small screen. The issue is that I am having to create each records html code by hand and then insert it into the HTML field. I would like HTML to be able to pull the fields it need in its own record. That way the program that displays it just shows the HTML with the correct info. Again...this is a project that I am very new to. Thanks for your help. |
Brian Chandler |
Oct 17 2007, 01:36 AM
Post
#4
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
QUOTE I would like HTML to be able to pull the fields it need in its own record. You really have to stop, breathe deeply, and think about what is going to do what. HTML is a markup language - it can't "pull" anything. If you currently have a bit of PHP that says: echo "<p>", $databaserow['description'], "</p>"; this copies the html text in the 'description' field to the output page. If instead you have fields with the name, colour, size, etc., you have to write a bit of PHP to concatenate these strings with whatever bits of grammar (etc) go between them. This is basic scripting stuff, and it's not desperately hard, but you have to practice a bit with a tutorial or similar. If it helps, here's a fragment of my search page, where the script is generating the title for the search. If you go to this page and try searches, you should be able to see how the title on the page matches this script: http://imaginatorium.org/shop/show.php CODE if ($cond == 1) $srchdesc .= "all "; if ($genre) $srchdesc .= "$gname "; $srchdesc .= "puzzles"; if ($time) $srchdesc .= ", " . orlist($tnames) . ","; if ($feat) $srchdesc .= " featuring " . orlist($fnames); if ($anames) $srchdesc .= " by artist " . orlist($anames); if ($pcs) $srchdesc .= " with $pcsdesc pieces"; if ($mfr) $srchdesc .= " made by " . orlist($mnames); if ($orient) $srchdesc .= ", $oname format"; You should also find it quite easy to provoke it into producing something ungrammatical, but then it is just a quick kludge at present... This post has been edited by Brian Chandler: Oct 17 2007, 01:37 AM |
WhiskeyDevil |
Oct 23 2007, 02:57 PM
Post
#5
|
Group: Members Posts: 3 Joined: 16-October 07 Member No.: 4,073 |
Sorry was out of the country for a few...
Deep Breaths...in...out. At this point I have to admit...I feel ridiculous asking these questions...but you have been very patient...thank you.. so one more. Here is the basic my table... Color Size Description Red 7 <html><div align=center>("COLOR")<br><table width=100%><tr><td>SIZE</td><td align=right>COLLECTION</td></tr><tr><td>***color Field***</td><td align=right>***Size Field***</td></tr></table><table width=100%><tr><td align=center>***Options Field***</td></tr></table> The main thing is I want to pull the fields into the description so I can send the HTML description to a display. I am sure that I am confused and that you are amazed by my shear ignorance...but I appreciate your insight. |
Darin McGrew |
Oct 23 2007, 05:18 PM
Post
#6
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
When you created this thread, you said that you already have a database, and that it includes "an html field that is sent to a pc to be displayed." Later, you described a program that "looks at the database to find the correct record" and then displays the HTML field.
So, what is this program that looks up the DB record and sends the HTML field? Whatever program this is, that is what you'll need to update. But you haven't told us enough about that program for us to offer any more substantial advice. |
Lo-Fi Version | Time is now: 28th April 2024 - 11:03 AM |