|
 |
|
ช่วยแก้วิธีการส่งค่าไปอีก form ให้ลงฐานข้อมูล มี3 ส่วน |
|
 |
|
|
 |
 |
|
---------------------------------------------------------------------------------------------------ส่วนที่ 1--------------------------------------
<form name="form1" method="post" action="listmenu.php">
<div align="center">
<p align="center"><img src="Image/logo5.png" width="100" height="30"><br>
<br>
<?
$host="localhost";
$username="thanet";
$password="094788508";
$connect= mysql_connect( $host,$username,$password);
if ( !$connect )
{
echo "ไม่สามารถติดต่อกับฐานข้อมูลได้ ";
exit();
}else{
/*Query ข้อมูลจากตาราง*/
$db="restuarant";
$sql="Select * From custumer ";
$db_query=mysql_db_query($db,$sql );
/*เอาข้อมูลไปใส่ในDropDown List*/
echo "<select name='dropdown1'<option value=' '></option>";
while($result = mysql_fetch_array($db_query)) {
echo "<option value='$result[table_id]'>$result[table_id]</option>";
}
echo "</select>";
}
mysql_close($connect);
?>
<input name="Submit" type="submit" class="style37" value="ตกลง">
</p>
</div>
</form>
---------------------------------------------------------------------------------------------------ส่วนที่ 2-------------------------------------
<form name="form1" method="post" action="storeorder.php">
<input type="hidden" name="dropdown1" value="$dropdown1">
<?
$host="localhost";
$username="thanet";
$password="094788508";
$db="restuarant";
$tb="food";
$charset = "SET character_set_results=tis620";
mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_query($charset) or die('ERROR Query:'.mysql_error());
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */
$sql="Select * From $tb";
$db_query=mysql_db_query($db,$sql);
$num_rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */
?>
<table width="100%" border="0" align="center" background="Image/logo11.gif">
<!--DWLayoutTable-->
<tr>
<td width="33" height="19" valign="top" background="Image/logo9.gif" class="style55">
<div align="center">รหัส</div></td>
<td width="130" valign="top" background="Image/logo9.gif" class="style55">
<div align="left"> รายการ</div></td>
<td width="51" valign="top" background="Image/logo9.gif" class="style55">
<div align="left"> เลือก</div></td>
</tr>
</table>
<?
$a=0;
while($a < $num_rows)
{
$result = mysql_fetch_array($db_query);
$food_id=$result[food_id];
$lists=$result[lists];
?>
<table width="100%" border="0" align="center">
<!--DWLayoutTable-->
<tr>
<td width="33" height="24" valign="middle" class="style45">
<div align="center">
<?echo"$food_id";?>
</div></td>
<td width="130" valign="middle" class="style45">
<div align="left">
<?echo"$lists";?>
</div></td>
<td width="51" valign="middle">
<div align="center" class="style44">
<select name="num" size="1" class="style44">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
</div></td>
</tr>
</table>
<?
$a++;
}
mysql_close();
?>
<input name="Submit" type="submit" class="style39" value="บันทึกรายการอาหาร">
</form>
---------------------------------------------------------------------------------------------------ส่วนที่ 3--------------------------------------
<?
$host="localhost";
$username="thanet";
$password="094788508";
$db="restuarant";
$connect= mysql_connect( $host,$username,$password);
mysql_select_db($db,$connect);
if ( !$connect )
{
echo "ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ";
exit();
}else{
echo "สามารถติดต่อกับฐานข้อมูล Mysql ได้ ";
echo "รายการอาหารจากโต๊ะ ".$dropdown1."<br>";
$table_id=$dropdown1[table_id];
$food_id=$result[food_id];
mysql_query("INSERT INTO orders (food_id,table_id, num) values($food_id,$table_id,$num)") or die ("เพิ่มข้อมูลลงในตารางไม่ได้ ");
}
mysql_close($connect);
?>
-------------------------------------------------------------------ด่วนครับ ขอบคุณครับ----------------------------------------------
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
28 ก.พ. 2550 12:31:59 |
By :
myboss |
View :
1795 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 00
|