時所顯示的錯誤,我有那些幫助更新和刪除表中的一行代碼:沒有更新和刪除
HTML:
<table class="imagetable" cellpadding="3" cellspacing="1" width="400px" border="1">
<th>ID</th>
<th>Name</th>
<th>Informations</th>
<th>Actions</th>
<tr>
<td><input type="text" name="id" value="<?php echo $rows['id'] ?>"/></td>
<td><input type="text" name="med_name" value="<?php echo $rows['med_name'] ?>"/></td>
<td><input type="text" name="info" value="<?php echo $rows['info']?>"/></td>
<td>
<form action="update_del.php" method="post">
<input class="imgClass_update" type="submit" name="submit1" value="" />
<input class="imgClass_dell" type="submit" name="submit2" value=""/>
</form>
</td>
</tr>
<tr>
PHP:
<?php
require_once('../include/global.php');
$id=$_POST['id'];
if(isset($_POST['submit1']))
{
$name=$_POST['med_name'];
$info=$_POST['info'];
$sql = "UPDATE med SET med_name='$name',
info='$info'
WHERE id='$id'";
$result=mysqli_query($con,$sql) or die('Unable to execute query. '. mysqli_error($con));
if($result){
header("location:med.php");
}
else
{
header("location:update_false.php");
}
}
if(isset($_POST['submit2']))
{
$sql = "DELETE FROM med WHERE id='$id'";
$result=mysqli_query($con,$sql) or die('Unable to execute query. '. mysqli_error($con));
if(mysqli_affected_rows($con) == 1)
{
header("location:med.php");
}
else
{
header("location:update_false.php");
}
}
?>
沒有什麼更新或刪除。並沒有顯示錯誤。如果有人可以幫助我,我認爲這個問題太簡單了,但是看不到它在哪裏。
那麼你的概率將不會看到錯誤,因爲您重定向之前,你甚至可以看到一個錯誤.. +你不張貼任何東西因爲你的表單只包含提交按鈕,而不是你正在尋找的輸入字段...... – Naruto
你能修復代碼嗎? – droidnation