0

Hi,

I make a delete page with php to delete clients from clients table. With this page I try to delete images from gallery table. for example I wish to delete client ABC from clients table and it have three images in gallery table.

here under I paste the code to delete the specific client and images, when I hit the delete button it goes to deleteclientpage but the specific client and images doesn't delete.

can anyone give me some help to make it work?

if (!empty($_GET["clientid"]))
    {
        $clientid = $_GET["clientid"];
        $query = "DELETE FROM clients, gallery WHERE clients.clientid = $clientid AND gallery.clientid = $clientid";
        //change the way the query is called
        $db->query($query);

        echo "<p id='text'>The client was deleted.</p>";
    }

Thanks.
marifard

5
Contributors
8
Replies
42
Views
3 Years
Discussion Span
Last Post by Ketul_1
0

pritaeas and thirsty.soul it dosn't show anything either with echo $query; or not.

0

I check my coding for another time and I solved it regarding to the begining of if statment because in a href name it id instead of clientid but when I try again to delete the page shows me this error shown below

4You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE clients.clientid = 4 AND gallery.clientid = 4' at line 1

0

as your code i understand. you have two table client and gallery. gallery have clientID for its Images. so u can do this way

first you checked in your URL There is a clientid or not without clientID code not work

    if (isset($_GET["clientid"]) || $_POST["clientid"])
    {
    $clientid = $_GET["clientid"];
    $query = "DELETE FROM clients WHERE clientid ='".$clientid."'";
    $db->query($query);
    $query1= "DELETE FROM gallery WHERE clientid ='".$clientid."'";
    $db->query($query1);
    echo "<p id='text'>The client was deleted.</p>";
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.