php - From where do i pass id to delete a record? -


how pass id delete record in code?

<form action="index.php">         <?php                      mysql_connect('localhost', 'root', '');             mysql_select_db('user');             $query = mysql_query("select * tbluser");             echo "<center>";             echo '<table style="border:solid 2px black;">';             while(($row = mysql_fetch_array($query)) != null) {                 echo '<tr>';                 echo '<td>' . $row['username'] . '</td>';                 echo '<td>' . $row['password'] . '</td>';                 echo '<td>' . $row['emailaddress'] . '</td>';                 echo '<td>' . $row['address'] . '</td>';                 echo '<td>' . $row['address'] . '</td>';                 echo '<td><input type = "submit" value = "delete" name = "btndel" /></td>';                 echo '</tr>';             }             echo '</table>';             echo "</center>";         ?>           </form> 

the above code in index.php , submitting itself.

without needing javascript, seperate urls etc, plain old html & original post: add id name of button:

<input type="submit" value="delete" name="btndel[<?php echo $id;?>]"> 

and in receiving code:

if(isset($_post['btndel']) && is_array($_post['btndel'])){     foreach($_post['btndel'] $id_to_delete => $useless_value){         //delete item $id_to_delete     } } 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -