 |
|
รบกวนพี่ๆช่วยดูโด้ดนี้ให้หน่อยครับ มันดึงรายชื่อมาโชว์นะครับ แต่พอเลือกแล้ว แล้วกดบันทึก มันดันบันทึกทุกค่า(ุทุกชื่อ)เลยครับ
เช่น เลือกชื่อ นายก. พอบันทึกปุ๊บ ในฐานข้อมูลจะ ขึ้น 001 นายก. 002 นาย.ข ....... ทุกค่า ทั้งๆที่เราเลือกแค่ค่าเดียวครับ
ขอคำแนะนำหน่อยครับ
ไฟล์ newhisform.php
Code
<form method="post" action="savehis.php">
<select name="txtcid">
<option value="0">เลือกลูกค้า</option>
<?php
$sql="select * from customer";
$result = SelectHis($sql);
foreach($result as $row)
{
$id=$row['c_id'];
$name = $row['c_fname'];
echo "<option value='$id'>$id - $name</option>";
}
?>
</select>
</form>
ไฟล์ savehis.php
Code (PHP)
<?php
include_once("function/history.php");
$id = $_POST["txthid"];
$cid = $_POST["txtcid"];
$denid = $_POST["txtdenid"];
$date= $_POST["txtdate"];
$datenext= $_POST["txtdatenext"];
$healname = $_POST["txthealname"];
$number = $_POST["txtnumber"];
$price = $_POST["txtprice"];
$detail = $_POST["txtdetail"];
$drugname = $_POST["txtdrugname"];
$money = $_POST["txtprice"] * $number = $_POST["txtnumber"];
$sql1 = "insert into history(h_id,c_id,den_id,h_date,h_datenext,heal_name,h_detail,drug_name,h_money)";
$sql2 = " values('$id','$cid','$denid','$date','$datenext','$healname','$detail','$drugname','$money')";
$sql = $sql1.$sql2;
$result = AddNewHis($sql);
if(!$result){
die("ไม่สามารถเพิ่มข้อมูลได้");
}else{
include_once("hislist.php");
}
?>
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2011-08-30 20:49:34 |
By :
tumnisit |
View :
722 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |