html - Delete data from table made with php echo? -


i have html table made php code, like:

while($row = mysqli_fetch_array($sql)){     echo "<tr>\n";     echo "<td>".$row['name'];     echo "<a href = "delete.php" "...>delete</a> " 

and want delete value link is; so.. know how delete data sql tables , stuff, question how store $row['name'] variable delete (with delete.php file).

if intent delete row, fetch id not name:

in loop:

echo "<a href='delete.php?id=".$row['id']."'>delete</a>"; 

then in delete.php:

<?php  if(isset($_get['id'])) {     $id = $_get['id'];      $con = new mysqli('localhost', 'username', 'password', 'database_name');     $sql = 'delete table_name id = ?';     $delete = $con->prepare($sql);     $delete->bind_param('i', $id);     $delete->execute();      if($delete->affected_rows > 0) {         header('location: back_to_that_page.php');     } }  ?> 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -