RE: [PHP] populating textboxes & list boxes from database fields

From: Date: Tue, 30 Apr 2002 14:43:21 +0000
Subject: RE: [PHP] populating textboxes & list boxes from database fields
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-95363@lists.php.net to get a copy of this message
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:menezesd@singnet.com.sg] > Sent: Tuesday, April 30, 2002 4:30 AM > To: php-general@lists.php.net > 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

« previous php.general (#95363) next »