populating forms from d/b?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
knight
Forum Newbie
Posts: 5
Joined: Tue Feb 25, 2003 5:34 pm
Location: B.C.

populating forms from d/b?

Post by knight »

Hi,
I'm doing a form to edit data from existing records in mysql d/b using
syntax:

<td> <input type=text name=author maxlength=30 size=30
value="<?php echo @$author ?>" ><br></td>

it all echoes properly except for a text area field using syntax:

<td><input type=textarea name=synopsis rows=4 cols=60
value="<?php echo @$synopsis ?>"></textarea> <br></td>

this shows blank on the form, but $synopsis does have the correct value.
does anyone know how to fix this?

also, I have another variable $genre, that I'd like to display in a select.
syntax is:
td><select name="genre">
<option value="Fiction">Fiction
<option value="Mystery">Mystery
<option value="Romance">Romance
<option value="SF/Fantasy">SF/Fantasy
<option value="War/Adventure">War/Adventure
<option value="Horror">Horror
<option value="Historical Fiction">Historical Fiction
<option value="Biography">Biography
<option value="True Crime">True Crime
<option value="Young Adult">Young Adult
<option value="Children">Children
<option value="Canadiana">Canadiana
</select><br></td>
When I try to echo $genre, it doesn't display.

Thanks in advance from a newbie:)
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

<option value="2" <? if (!(strcmp("2", $genre))) {echo "SELECTED";} ?>>

how are you getting the data from the db??
knight
Forum Newbie
Posts: 5
Joined: Tue Feb 25, 2003 5:34 pm
Location: B.C.

Post by knight »

:) That worked great. Thanks for your help.
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

try replacing
<td><input type=textarea name=synopsis rows=4 cols=60
value="<?php echo @$synopsis ?>"></textarea> <br></td>
with
<td><textarea name=synopsis rows=4 cols=60>
<?php echo @$synopsis ?></textarea> <br></td>
Post Reply