Jump to content

Delete help.


Lee-Bartlett

Recommended Posts

Ok i wanna delete a row in a db where the id and the name match, this code works if i wanna either delete by name or id, but if i put both in there it fails. Ofc if 2 people have same name, that will pose a problem, so id + name is best way to delete it. Here is my code, where am i going wrong, I have tried AND where the comma is to

 

<?php  require_once("includes/db_connection.php"); ?> 

<?php
$id = $_POST['id']; 
$name = $_POST['name']; 


?> 

<?php

  $delete = mysql_query("DELETE FROM tblbasicform WHERE id='$id', name='$name'");

  
$sql = "SELECT * from tblbasicform";
$res = mysql_query($sql) or die(mysql_error());

echo "<form action=\"\" method=\"post\">";
echo "<select name=\"name\">";

while($row = mysql_fetch_array($res)){

echo "<option>". $row['id'], $row['name'];
        echo "</option>";
$name = $row['name'];
    $email = $row['email'];
    $location = $row['location'];
$buissnes_name = $row['buissnes_name'];
$type = $row['type'];
$id = $row['id'];
  }
echo "</select><br>";
echo "<input type=submit value=\"Delete Record\">";
echo "</form>";




?>

Link to comment
https://forums.phpfreaks.com/topic/127039-delete-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.