Get Options from MySQL
HTML input forms have option boxes. These options we can get from MySQL table field.For this tutorial too,I have used the table vehicle in page(MySQL standard deviance and variance)
<SELECT> <?php @ $db = mysql_connect("localhost", "root", ""); mysql_select_db("my_database"); $strSQL = "SELECT * FROM vehicle ORDER BY Type"; $rs = mysql_query($strSQL); $nr = mysql_num_rows($rs); for ($i=0; $i<$nr; $i++) { $r = mysql_fetch_array($rs); echo "<OPTION VALUE=\"".$r["Type"]."\">".$r["Type"]."</OPTION>"; } ?> </SELECT> |
No comments:
Post a Comment