Re: How can I include mysql-query results as <options> in a html-skript?

From: Date: Mon, 09 Oct 2000 15:05:06 +0000
Subject: Re: How can I include mysql-query results as <options> in a html-skript?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19199@lists.php.net to get a copy of this message
You can do this.... Tested and working.... <Select Name="matrikelnummer"> <script language="php"> $query = ("SELECT matrikelnummer FROM diplomanden ORDER BY matrikelnummer"); $result = mysql_query($query, $db);
     if(mysql_num_rows($result)) {
       // we have at least one option, so show all matrikelnummeren as options in select form
       while($row = mysql_fetch_row($result))
       {
          print("<OPTION value=\"$row[0]\">$row[0]");
       }
     } else {
       print("<OPTION value=\"\">No components have been entered yet");
     }
</script> </Select> Best, -Ben At 04:07 PM 10/9/2000 +0200, Joachim Ritzer wrote:
hi everybody, Since a few days I try to include the result of a MySQL-query as options into html-skript. I know this sentence is not very precise, but if you may take a look on the following lines (see <OPTION>) you will know what I´m talking about. <? $query = ("SELECT matrikelnummer FROM diplomanden ORDER BY matrikelnummer"); $result = mysql_query($query, $db); $number = mysql_num_rows($result); $matrikelnummer = mysql_fetch_array($result,MYSQL_NUM); ?> ... <TR>
        <TD bgColor=#ffe4b5>Matrikelnummer:</TD>
        <TD><SELECT id="" name=matrikelnummer
                  style="HEIGHT: 22px; WIDTH: 150px">
          <OPTION > (here should be the first element of the array
$matrikelnummer)
          <OPTION >(here the 2nd)
          <OPTION> (3rd .....)
        </SELECT>
Thanks to everybody and maybe next time I will be able to help. Regards Joachim. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#19199) next »