php - Delete a row from MySql -


i attempting add button html table allow user delete specific row when clicked.

i have following far not understand why corresponding database table row not being deleted when click borrar (delete) button.

what part missing?

<?php { ?>   <table width="263" border="1">     <tr>       <td><?php echo $row_recordset1['name']; ?></td>       <td><form id="form1" name="form1" method="post" action="">         <input type="submit" name="borrar" id="borrar" value="borrar" />       </form></td>     </tr>   </table>   <?php } while ($row_recordset1 = mysql_fetch_assoc($recordset1)); ?>  <?php  if(isset($_post['borrar'])){    if ((isset($_post['id'])) && ($_post['id'] != "")) {   $deletesql = sprintf("delete carrito id=%s",                        getsqlvaluestring($_post['id'], "int"));    mysql_select_db($database_py, $py);   $result1 = mysql_query($deletesql, $py) or die(mysql_error());    $deletegoto = "http://fb.com";   if (isset($_server['query_string'])) {     $deletegoto .= (strpos($deletegoto, '?')) ? "&" : "?";     $deletegoto .= $_server['query_string'];   }   header(sprintf("location: %s", $deletegoto)); } } ?> </body> </html> <?php mysql_free_result($recordset1); ?> 

you're not passing row 'id' form.

<table width="263" border="1">     <tr>       <td><?php echo $row_recordset1['name']; ?></td>       <td><form id="form1" name="form1" method="post" action="">          <!-- new line below  -->         <input type="hidden" name="id" value="<?php echo $row_recordset1['id']; ?>" />          <input type="submit" name="borrar" id="borrar" value="borrar" />       </form></td>     </tr>   </table> 

your form should example above.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -