Pull your data from the database, assign it to a variable, and echo it's
value to the text box.

<input type='text' name'whatever' value='<?=$DB_Row["Column"]?>'>

For drop down boxes, it's a little different. You have to check each
value to see if it equals your DB value, and if it does, echo
"selected".

<select name='something'>
<option value='1' <? if($DB_Row["Col"] == '1') { echo " selected"; }
?>>One</option>
<option value='2' <? If($DB_Row["Col"] == '2') { echo " selected"; }
?>>Two</option>
</select>

I find it easier to use global arrays and functions to create select
boxes. Makes for cleaner code.

---John Holmes...

> -----Original Message-----
> From: Denis L. Menezes [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 30, 2002 4:30 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] populating textboxes & list boxes from database fields
> 
> Hello friends,
> 
> Can someone please tell me where I can find sample scripts for
populating
> textboxes and listboxes on a form(when the form opens) using the data
from
> fields in a table?
> 
> Thanks
> Denis
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to