我收到了一個表單來編輯關於餐廳的數據。然後,在表單裏面放一個按鈕來刪除圖像。這是我的代碼:在php表格中刪除圖像
echo "<form name='form_update1' method='post' action='editrestaurant_post.php' enctype='multipart/form-data' >\n";
echo '<table width="50%">';
echo '<tr>';
echo '<td>Edit Restaurant</td>';
echo '</tr>';
echo '<tr>';
echo "<td> </td>";
echo '</tr>';
while ($fp = mysql_fetch_array($rsP)) { // loop as long as there are more results
$proid = mysql_real_escape_string($fp['proid']);
$proid = is_array($proid) ? $proid[count($proid)-1] : $proid;
echo '<tr>';
echo "<td> </td>";
echo "<td><input type='hidden' size='40' name='proid[$p]' value='{$fp['proid']}' /></td>";
echo '</tr>';
echo '<tr>';
echo "<td>Restaurant Name :</td>";
echo "<td><input type='text' size='40' name='resName[$p]' value='{$fp['resName']}' /></td>";
echo '</tr>';
$sqlPi= "SELECT * FROM pimage WHERE pimage.proid ='" . $proid . "'";
$rsPi = mysql_query($sqlPi) or die($sqlPi."<br/><br/>".mysql_error());
$pi = 0;
while ($fpi = mysql_fetch_array($rsPi)) {
$image = mysql_real_escape_string($fpi['image']);
$image = is_array($image) ? $image[count($image)-1] : $image;
$id = mysql_real_escape_string($fpi['id']);
$id = is_array($id) ? $id[count($id)-1] : $id;
echo "<form method='post' action='delete_image.php'>\n";
echo '<tr>';
echo "<td>Image :</td>";
echo "<td><img src='client_images".$fpi['image']."' width='50' height='50' ><input type='submit' name='deletepi' id='deletepi' value='Delete Image'></td>";
echo "<td><input type='hidden' size='40' name='imid' value='{$id}' /><input type='hidden' size='40' name='dir' value='{$image}' /><input type='hidden' size='40' name='e' value='{$e}' /></td>";
echo '</tr></form>';
++$pi;
}
++$p;
}
echo'<tr>
<td colspan="3" align="center"><input type="submit" name="button1" id="button1" value="Submit1"></td>
</tr>
</table>
</form>';
問題是,當我點擊刪除按鈕,它確實像主編輯餐廳形式的行動。我怎麼能解決這個問題?感謝:D,非常感謝你的幫助
你的代碼真的很亂,很難閱讀。然而,對於初學者來說,你有一個'
請參閱http://stackoverflow.com/questions/379610/can-you-nest-html-forms – VolkerK