Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabase delete initiated from a web page does not seem to work
    text
    copied!<p>I have a problem in delete item. My problem is when I click on delete the button the item does not disappear but when I refresh it it does disappear.</p> <p>And this is my code : </p> <p>index.php</p> <pre><code>&lt;?php $config = mysql_connect("localhost", "root", "") or die (mysql_error()); $db = mysql_select_db("darith_upload_img",$config) or die (mysql_error()); ?&gt; &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;form action="upload_process.php" enctype="multipart/form-data" method="POST"&gt; &lt;input type="file" name="img" /&gt;&lt;br /&gt; &lt;input type="submit" value="upload Now" /&gt; &lt;/form&gt; &lt;?php $result = mysql_query("SELECT * FROM table_img"); while($row = mysql_fetch_array($result)) { $id = $row['id_img']; ?&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $row['id_img']; ?&gt;&lt;/td&gt; &lt;td width="200" &gt;&lt;?php echo $row['location_img']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo '&lt;img src="' . $row['location_img'] . '" width="60"/&gt;'; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="index.php?id=&lt;?php echo $id;?&gt; " onClick="return confirm('Are you sure?')"&gt;Delete&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;?php } ?&gt; &lt;?php if(isset($_GET['id'])){ $id_img=$_GET['id']; $q_del=mysql_query("DELETE FROM table_img where id_img ='$id_img'"); header("Location: http://example.com/path/to/index.php"); } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>upload_process.php</p> <pre><code>&lt;?php $config = mysql_connect("localhost", "root", "") or die (mysql_error()); $db = mysql_select_db("darith_upload_img", $config) or die (mysql_error()); if(isset($_FILES["img"]["tmp_name"])) { move_uploaded_file($_FILES["img"]["tmp_name"], "picture/". $_FILES["img"]["name"]); $location = "picture/".$_FILES["img"]["name"]; $save = mysql_query("INSERT INTO table_img (location_img) VALUES ('$location')"); header("Location: http://example.com/path/to/index.php"); } exit(); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload