RE: Code for drop down lists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux