|
 |
|
สอบถาม ต้องการเขียนคำสั่ง เปรียบเทียบค่าใน select เวลาเรา จะแก้ไข ให้เลือกค่าปัจจุบันที่อยู่ในฐานข้อมูล |
|
 |
|
|
 |
 |
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<?
$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>
<?
$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="<?=$objResuut["CustomerID"];?>" <?=$sel;?>><?=$objResuut["CustomerID"]." - ".$objResuut["Name"];?></option>
<?
}
?>
</select>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
<?
mysql_close();
?>
Go to : PHP MySQL DropDownList / Listmenu / ListBox
|
 |
 |
 |
 |
Date :
2011-09-05 21:06:51 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|