<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <?php mysql_connect("localhost","root","root") or die(mysql_error()); mysql_select_db("mydatabase"); ?> <body> <form action="phpLlistmenuDatebase2.php" method="post" name="form1"> List Menu<br> <select name="lmName1"> <option value=""><-- Please Select Item --></option> <?php $strSQL = "SELECT * FROM customer ORDER BY CustomerID ASC"; $objQuery = mysql_query($strSQL); while($objResuut = mysql_fetch_array($objQuery)) { ?> <option value="<?php echo $objResuut["CustomerID"];?>"><?php echo $objResuut["CustomerID"]." - ".$objResuut["Name"];?></option> <?php } ?> </select> <input name="btnSubmit" type="submit" value="Submit"> </form> </body> </html> <?php mysql_close(); ?>
<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <?php mysql_connect("localhost","root","root") or die(mysql_error()); mysql_select_db("mydatabase"); ?> <body> <?php echo $_POST["lmName1"]; echo "<hr>"; $strSQL = "SELECT * FROM customer WHERE CustomerID = '".$_POST["lmName1"]."' "; $objQuery = mysql_query($strSQL); $objResult = mysql_fetch_array($objQuery); echo $objResult["Name"]; ?> </body> </html> <?php mysql_close(); ?>
<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <?php $strDefault = "C003"; mysql_connect("localhost","root","root") or die(mysql_error()); mysql_select_db("mydatabase"); ?> <body> <form action="phpLlistmenuDatebase2.php" method="post" name="form1"> List Menu<br> <select name="lmName1"> <option value=""><-- Please Select Item --></option> <?php $strSQL = "SELECT * FROM customer ORDER BY CustomerID ASC"; $objQuery = mysql_query($strSQL); while($objResuut = mysql_fetch_array($objQuery)) { if($strDefault == $objResuut["CustomerID"]) { $sel = "selected"; } else { $sel = ""; } ?> <option value="<?php echo $objResuut["CustomerID"];?>" <?php echo $sel;?>><?php echo $objResuut["CustomerID"]." - ".$objResuut["Name"];?></option> <?php } ?> </select> <input name="btnSubmit" type="submit" value="Submit"> </form> </body> </html> <?php mysql_close(); ?>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท