[FONT=Courier]I have a table called information that contains 2 fields – one called description and one called content. I would like to create a script that takes everything in the description field and puts them into either buttons or clickable text (preferably clickable text). When the user clicks on the description, whatever is in the corresponding content field is displayed in a text area box at the top of the screen.
Is creating clickable text that contains dynamically created functions doable in PHP? If so, I am sure that that is how this should be approached. That would mean that I should put something in the while loop (please see the code below). If you have any tips, suggestions, or code that you can throw at me, it would be very much appreciated.
Thanks!
The table will look something like this –
description ......... content
a red wagon ......... the red wagon is a radio flyer
silver cell phone ... i use this to call people
noisy truck ......... it is very annoying
A typical page would look like the following -
----------------------------
| it is very annoying .... |
| ........................ |
| ........................ |
| ........................ |
| ........................ |
| ........................ |
| ........................ |
a red wagon
silver cellular phone
noisy truck
In this example, because the user clicked on “noisy truck”, “it is very annoying” showed up in the text area at the top.
The following code is what I came up with so far (minus all the database connection stuff). It creates the text area and will list everything in the description field below the text area.
<form action="<?php echo($php_self); ?>" method=post>
<textarea name="contentArea" cols=60 rows=20></textarea>
</form>
<?php
$query = "SELECT * FROM information";
$result = mysql_query( $query ) or die( mysql_error() );
while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) )
{
echo "{$row['description']}<p>";
}
?>[/COLOR][/SIZE]
[/FONT]