PHP - MySQL - Delete Row

前端 未结 4 841
梦如初夏
梦如初夏 2020-12-11 03:02

I am not too sure what i am doing wrong. i am trying to delete the entire row with this code but it is not working. No error is happening it prints the line that it was dele

相关标签:
4条回答
  • 2020-12-11 03:53

    I got it working using this code!

    <?php
    $id =$_REQUEST['id'];
    
    $con = mysql_connect("localhost","username","password");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("database", $con);
    
    // sending query
    mysql_query("DELETE FROM times WHERE id = '$id'")
    or die(mysql_error());      
    
    ?>
    
    0 讨论(0)
  • 2020-12-11 03:53
    delete.php
    
    <?php
        include "connect.php";
        $id =$_REQUEST['id'];
    
        // sending query
        mysql_query("DELETE FROM utilizatori WHERE id = '$id'")
        or die(mysql_error());      
    
        ?>
    

    is corect, I tested and delete from ID

    and here is the button delete: `

    <?<a href=\"delete.php?id=$row[id]\">Delete</a>`?>
    
    0 讨论(0)
  • 2020-12-11 03:57
    else
        {
        $qry = "SELECT * FROM my_login WHERE email = '".$email."' LIMIT 1";
        $res = mysql_query($qry);
        if(mysql_num_rows($res) > 0)
            {
            echo "Email already exists!";
            }
        else
            {
            $qry="INSERT INTO my_login SET name='$name',city='$city',comment='$comt',password='$pass',email='$email'";
            mysql_query($qry);
            }
        }       
    }
    ?>  
    
    0 讨论(0)
  • 2020-12-11 04:01

    You used $order instead of your query variable $sql

    $sql="DELETE FROM times WHERE id='$id'";
    mysql_query($sql);
    
    0 讨论(0)
提交回复
热议问题