Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to delete rows through php, HTML
    primarykey
    data
    text
    <p>I am just unable to understand why the rows are not getting deleted! please note that i am getting the login values of corrected check boxes in the php page. from my point of view, most probably error should be in php page where i am using 'DELETE FROM' query.</p> <pre><code>&lt;?php session_start(); ?&gt; &lt;html&gt; &lt;head&gt; &lt;form id="delete_customers" action="deletecustomers.php" method="post"&gt; &lt;?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("car_rental_system", $con); $result = mysql_query("SELECT * FROM customer"); echo "&lt;table border='1' align='center'&gt; &lt;tr&gt; &lt;th&gt;first_name&lt;/th&gt; &lt;th&gt;Last_name&lt;/th&gt; &lt;th&gt;login&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['first_name'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['login'] . "&lt;/td&gt;"; echo "&lt;td&gt;"."&lt;input type='checkbox' name='deletingcustomers[]' value=$row['login']}"."&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; mysql_close($con); ?&gt; &lt;p class='submit'&gt; &lt;button type='submit' name='dscustomer'&gt;Delete selected&lt;/button&gt; &lt;/p&gt; &lt;/head&gt; &lt;/html&gt; </code></pre> <p>//NOW deletecustomers.php</p> <pre><code>&lt;?php session_start(); $_SESSION['deletingcustomers'] = $_POST['deletingcustomers']; $N = count($_SESSION['deletingcustomers']); $con = mysql_connect("localhost","root",""); if (!$con) die('Could not connect: ' . mysql_error()); mysql_select_db("car_rental_system", $con); if(empty($_SESSION['deletingcustomers'])) { echo("No customers selected"); } else { for ($i=0; $i&lt;$N; $i++) { $sql1="delete from `customer` where login='{$_SESSION[deletingcustomers][$i]}'"; if(mysql_query($sql1,$con)) echo 'executed'; } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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