ผู้รู้ช่วยดูโค้ดนี้ให้หน่อยครับมัน error เวลา input พร้อมกันตั้งแต่ 2 input ขึ้นไป แล้ว submit
โค้ดที่ใช้
Code (PHP)
....
<?
$text = $_POST[txtid_in_department];
$text1 = $_POST[text1];
if (isset($text)) {
$sql = "";
for ($i = 1; $i <= count($text); $i++) {
if ($text[$i] != "")
{ $sql .= "INSERT INTO tbl_in_receive(id_in_receive,id_in_department) VALUES ('$text1[$i]','$text[$i]'); ";
//$sql .= "UPDATE books_received SET r_pass= '$text[$i]' WHERE id_r in ($text1[$i])";
}
};
echo $sql;
$result=mysql_query($sql,$Connect) or die(mysql_error());
// $result1=mysql_query($sql1,$Connect) or die(mysql_error());
}
?>
<?
$sqlreceive="select * from books_received r,user_login u,tbl_lavel l where r.u_record = u.u_record and r.lavel_r= l.id_lavel and r.r_pass='' ";
$dbqueryreceive= mysql_query($sqlreceive);
$Num_Rows = mysql_num_rows($dbqueryreceive);
$Per_Page = 20; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$sqlreceive .=" order by r.id_r desc LIMIT $Page_Start , $Per_Page";
$dbqueryreceive = mysql_query($sqlreceive);
$x=1;
while($objResult = mysql_fetch_array($dbqueryreceive))
{
if($bg == "#66ffff") { //ส่วนของการ สลับสี
$bg = "#ffffff";
} else {
$bg = "#66ffff";
}
?>
<form name="form1" method="post" action="send_after_pass.php">
<tr bgcolor="<?=$bg?>">
<td height="23" valign="middle" class="formpanel2"> <?=$objResult ["id_r"];?> </td>
<td valign="middle" class="formpanel2"><?=$objResult ["num_r"];?></td>
<td valign="middle" class="formpanel2"><?=$objResult ["date_r"];?></td>
<td valign="middle" class="formpanel2"><?=$objResult ["from_r"];?></td>
<td valign="middle" class="formpanel2"><?=$objResult ["to_r"];?></td>
<td valign="middle" class="formpanel2"><?=$objResult ["title_r"];?></td>
<td valign="middle" class="formpanel2"><?=$objResult ["n_lavel"];?></td>
<td valign="middle" class="formpanel2"><?=$objResult ["u_n_name"];?></td>
<td align="center" valign="middle" class="formpanel2"><select type="text" name="txtid_in_department[<?=$x;?>]" id='txtid_in_department' class="formpanel2">
<option value="">เลือกฝ่าย </option>
<option value="1">ฝ่ายบริหาร</option>
<option value="2">ฝ่ายส่งเสริมฯ</option>
<option value="3">ฝ่ายต่างด้าว</option>
<option value="4">ฝ่ายตรวจฯ</option>
<option value="5">ผู้อำนวยการ</option>
</select></td>
</tr>
<input type="hidden"name="text1[<?=$x;?>]" value="<?=$objResult ["id_r"];?>" />
<?
$x++;
}
?>
<tr>
<td height="338" > </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="27" colspan="9" valign="top" ><div align="center"><input name="btnAdd" type="submit" value="บันทึก" />
<input name="btnReset" type="reset" value="ยกเลิก" /></div></td>
</tr>
</form>
....
ค่าที่ Error
INSERT INTO tbl_in_receive(id_in_receive,id_in_department) VALUES ('0004','2'); INSERT INTO tbl_in_receive(id_in_receive,id_in_department) VALUES ('0003','3'); You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; INSERT INTO tbl_in_receive(id_in_receive,id_in_department) VALUES ('0003','3')' at line 1Tag : PHP, MySQL
Date :
2011-01-13 11:23:31
By :
eakloso
View :
604
Reply :
2
$sql .= มัน ต่อกับอะไรหละคับ ไม่ต้องมี .= ลอง = เฉยๆ
Date :
2011-01-13 12:01:47
By :
teez1232002
ขอบคุณมากครับ
Date :
2011-01-13 12:21:18
By :
eskloso
Load balance : Server 00