我試圖更新表(單),域(檢查),如果用戶選中複選框 場(選中)將數據庫表更新不起作用?
第1頁:detail.php
while($row = mysql_fetch_array($results))
{
$ch=$row['checked'] ;
$idw=$row['key'];
}
然後我檢查,如果用戶之前,檢查該行或不如果不是,我送鑰匙&以託運形式做檢查過程:
if ($ch==1)
{
echo "this record has been checked";
}
else
{
echo "<form action=\"checked.php\" method=\"GET\" enctype=\"multipart/form-data\" >";
echo "<input type=\"hidden\" name=\"ids\" value=\"$idw\" ><br>";
echo "<input type=\"checkbox\" name=\"check\" value=\"checked\" ><br>";
echo "<p><input name=\"submit\" type=\"submit\" value=\"submit\" /></p>";
echo "</form>";
}
第2頁:checked.php
$idw=$_GET['ids'];
$check=$_GET['check'];
$sql="UPDATE bill SET checked=1 where key=$idw";
$results=mysql_query($sql);
if ($results)
{
echo "the record has been updated successfully";
}
更新用沒有工作了,任何幫助,請
請格式化您的代碼。 –
請注意,這段代碼真的不安全。爲了避免sql注入,你應該使用:'$ idw =(int)$ _GET ['ids'];',至少如果GET應該包含一個int值。 – regilero