 |
|
|
 |
 |
|
///////////สร้างฐานข้อมูล////////////////
CREATE TABLE `product` (
`product_id` int(3) NOT NULL default '0',
`product_name` varchar(225) NOT NULL default '',
`product_cost` decimal(10,2) NOT NULL default '0.00',
`product_unit` varchar(125) NOT NULL default '',
PRIMARY KEY (`product_id`)
) TYPE=MyISAM;
#
# dump ตาราง `product`
#
INSERT INTO `product` VALUES (1, 'A', '10.00', 'g.');
INSERT INTO `product` VALUES (2, 'B', '15.00', 'kg.');
INSERT INTO `product` VALUES (3, 'C', '8.00', 'bag');
/////////////ส่วนของโค้ดโปรแกรมจ้า/////////
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<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>
</head>
<body>
สินค้า :
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="<? echo"?";?>">++++เลือกสินค้า</option>
<? $link = mysql_connect("localhost","","") or die ("Could not connect!!");
$dbname=mysql_select_db("test")or die ("Could not select database!!");
$query="select*from product";
$data_query=mysql_query($query,$link);
while($arr=mysql_fetch_array($data_query))
{ $product_id=$arr[product_id];
$product_name=$arr[product_name];
$product_cost=$arr[product_cost];
$product_unit=$arr[product_unit];
?>
<option value="<? echo"?product_id=$product_id&product_cost=$product_cost&product_unit=$product_unit";?>"<? if($product_id==$_GET[product_id])echo"selected";?>><?=$product_name;?></option>
<? }?>
</select>
ราคา : <input type="text" name="textfield2" value="<?=$_GET[product_cost];?>">
หน่วย : <input type="text" name="textfield" value="<?=$_GET[product_unit];?>">
</body>
</html>
**เป็นตย. นะจ๊ะ แล้วแต่การประยุกต์นำไปใช้ละกันค่า... 
|
 |
 |
 |
 |
Date :
25 พ.ค. 2550 15:32:24 |
By :
kudo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุนมากๆๆๆๆๆๆๆนะคับ กับคุณkudo
|
 |
 |
 |
 |
Date :
25 พ.ค. 2550 16:02:43 |
By :
noom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|