PHP Mysql delete Query not working properly

前端 未结 3 1871
逝去的感伤
逝去的感伤 2021-01-22 05:24

I am pulling a list of products from my MYSQL database and using a delete button against each product in case the operator wants to delete the product.

The problem is th

3条回答
  •  有刺的猬
    2021-01-22 05:44

    $link=mysqli_connect("localhost","root","","smartcart");
        $prod="select * from products";
        $rw=mysqli_query($link,$prod) or die(mysqli_errno()."in query $prod");
        $count=1;
        while($row=mysqli_fetch_assoc($rw))
        {
            echo "";
            echo "".$count."";
            echo "".$row['prod_id']."";
            echo "".$row['prod_name']."";
            echo "".$row['prod_price']."";
            echo "
    "; echo ""; echo ""; echo "
    "; $count=$count+1; }

    for delete action code in delete_prod.php

         if(isset($_GET['delete']))
    {
        include "connection.php";
        $prod_id=$_REQUEST['prod_id'];
            $del="delete from products where prod_id=$prod_id";
        if (mysqli_query($link,$del))
        {
            echo "Successfully deleted";
            unset($_GET['delete']);
        }
        else
        {
            echo "Delete operation Failed";
        }
        header('location:show_db.php');
    }
    

    try this...

提交回复
热议问题