RE: [PHP-DB] Code for drop down lists

From: Date: Tue, 11 Feb 2003 18:02:25 +0000
Subject: RE: [PHP-DB] Code for drop down lists
Groups: php.db 
Request: Send a blank email to php-db+get-25565@lists.php.net to get a copy of this message
Always use a DB when you can, makes it much easier to change params. Here's a snippet you can use: ################### SELECT BOX CODE ####################### echo ' <td><SELECT NAME="change" SIZE="1">'; $sql = "SELECT * from ai.reports order by name"; $selections = get_rowset($conn_id,$sql); foreach($selections as $selection){ echo '<OPTION'; $reptmp = $selection['name']; if ($val == $reptmp){ echo ' SELECTED'; } echo '>' . $selection['name']; } echo '</select></td>'; ########################################################## CAVEATS: The get_rowset is a function we've written for retrieving an array from the DB The if $val == $reptmp is to check for whatshould be selected Gary Every Sr. UNIX Administrator Ingram Entertainment (615) 287-4876 "Pay It Forward" mailto:gary.every@ingramentertainment.com http://accessingram.com -----Original Message----- From: Roland Perez [mailto:Roland.Perez@usdoj.gov] Sent: Tuesday, February 11, 2003 11:03 AM To: php-db@lists.php.net Subject: [PHP-DB] Code for drop down lists I am a novice to PHP and am trying toget a survey with drop down lists. I am stuck as to if I should connect to the DB (MySQL DB) to get the values from a table or do I imbed them in the php file? Thanks for any help in advance. Roland Perez roland.perez@usdoj.gov -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#25565) next »