|
 |
|
สอบถามหน่อยครับ checkbox แล้วค่าที่เข้าไปไม่ตรงกับที่เลือก เป็นเพราะอะไรหรอครับ |
|
 |
|
|
 |
 |
|
มันจะมี 4 ช่องให้เลือก 1 2 3 4
*ถ้าเลือกช่อง 3,4 ข้อมูลที่เข้ามันเป็นข้อมูลของช่อง 1กับ 2
*ถ้าเลือกช่อง 1,3,4 ข้อมูลที่เข้ามันเป็นข้อมูลของช่อง 1, 2,3 เหมือนมันนับจำนวนที่เลืิอกว่าเลือกกี่ช่อง
มันไม่ได้บันทึกตามข้อมูลช่องที่เลือก
test01
<form name="frmMain" action="test02.php" method="post" OnSubmit="return onSave();">
<?
$objConnect = mysql_connect("localhost","root","12345678") or die("Error Connect to Database");
$objDB = mysql_select_db("checking_tuberculosis");
$strSQL = "SELECT * FROM drug";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="1000" border="1">
<tr>
<th width="91"> <div align="center">รหัสยา </div></th>
<th width="98"> <div align="center">ชื่อทางการค้า </div></th>
<th width="98"> <div align="center">ชื่อทางการแพทย์</div></th>
<th width="197"> <div align="center">วิธีการใช้ยา</div></th>
<th width="159"> <div align="center">ผลข้างเคียง </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><input type="text" value="<?=$objResult["id_drug"];?>"</td>
<td><input type="text" name="chknamem[]" value="<?=$objResult["name_medicine"];?>"</td>
<td><input type="text" name="chknamep[]" value="<?=$objResult["name_physician"];?>"</td>
<td><input type="text" name="chkdos[]" value="<?=$objResult["dosageadult"];?>"</td>
<td><input type="text" name="chksid[]" value="<?=$objResult["sideeffect"];?>"</td>
<td><input type="checkbox" name="chkEmail[]" value="<?=$objResult["id_drug"];?>">
</td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
<input type="submit" name="btnSave" value="Save">
test02
<?
$objConnect = mysql_connect("localhost","root","12345678") or die("Error Connect to Database");
$objDB = mysql_select_db("checking_tuberculosis");
for($i=0;$i<count($_POST["chkEmail"]);$i++)
{
if($_POST["chkEmail"][$i] != "")
{
$strSQL = "INSERT INTO drugorder (name_medicine,name_physician,dosageadult,sideeffect,id_drug,firstname,auto_idpatient,DoctorID,n_doctor) VALUES ('".$_POST["chknamem"][$i]."','".$_POST["chknamep"][$i]."','".$_POST["chkdos"][$i]."'"
. ",'".$_POST["chksid"][$i]."','".$_POST["chkEmail"][$i]."','".$_POST["firstname"]."','".$_POST["auto_idpatient"]."','".$_POST["DoctorID"]."','".$_POST["n_doctor"]."')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
}
}
echo "<script type='text/javascript'>";
echo "alert('เพิ่มข้อมูลเรียบร้อย');";
echo "window.location='test01.php';";
echo "</script>";
mysql_close($objConnect);
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2018-04-21 10:07:43 |
By :
benlovehi5 |
View :
1019 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีหน้าโปรแกรมให้ดูด้วยก็ดีนะครับ เผื่อท่านผู้รู้มาเห็นจะได้ช่วยตอบ
|
 |
 |
 |
 |
Date :
2018-04-24 09:50:23 |
By :
nobetaking |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เช็ค name ที่เป็น array ให้ดีครับ ว่าค่าส่งมาถูกไหม
การนับของ count($_POST["chkEmail"]) ค่าที่จะเอามาวนลูปมันไม่ครบหรือเปล่า
|
 |
 |
 |
 |
Date :
2018-04-24 10:34:17 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","12345678") or die("Error Connect to Database");
$objDB = mysql_select_db("checking_tuberculosis");
for($i=0;$i<count($_POST["chkEmail"]);$i++)
{
if($_POST["chkEmail"][$i] != "")
{
$strSQL = "INSERT INTO drugorder (name_medicine,name_physician,dosageadult,sideeffect,id_drug,firstname,auto_idpatient,DoctorID,n_doctor)
VALUES ('".$_POST["chknamem"][$i]."',
'".$_POST["chknamep"][$i]."',
'".$_POST["chkdos"][$i]."',
'".$_POST["chksid"][$i]."',
'".$_POST["chkEmail"][$i]."',
'".$_POST["firstname"]."',
'".$_POST["auto_idpatient"]."',
'".$_POST["DoctorID"]."',
'".$_POST["n_doctor"]."')";
$objQuery = mysql_query($strSQL) or die ("Error Query".mysql_error());
}
}
echo "<script type='text/javascript'>";
echo "alert('เพิ่มข้อมูลเรียบร้อย');";
echo "window.location='test01.php';";
echo "</script>";
mysql_close($objConnect);
?>
-------------
Errors = '" '"' . ,
|
 |
 |
 |
 |
Date :
2018-04-24 10:48:22 |
By :
Hararock |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|