|
|
|
ต้องการเขียนโค้ด เมื่อคลิกเลือก selectbox แล้ว ส่งค่า id ของ selectbox ไปติดต่อ db เพื่อนำ้ข้อมูลอื่นๆมาแสดงใน textbox อื่นๆ ขอแนวทางหน่อยค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<body>
<form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1">
<tr>
<th>Country Code
<select name="ddlCountryCode" id="ddlCountryCode" onChange="MM_jumpMenu('parent',this,0)">
<option>- Select Country Code -</option>
<option value="<?=$_SERVER["PHP_SELF"];?>?Counter=TH">TH</option>
<option value="<?=$_SERVER["PHP_SELF"];?>?Counter=EN">EN</option>
<option value="<?=$_SERVER["PHP_SELF"];?>?Counter=US">US</option>
</select>
</th>
</tr>
</table>
</form>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
// Search By Name or Email
$strSQL = "SELECT * FROM customer WHERE 1 ";
if($_GET["Counter"] != "")
{
$strSQL .= " AND (CountryCode = '".$_GET["Counter"]."') ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
|
|
|
|
|
Date :
2012-07-07 11:45:15 |
By :
000su000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|