0

I already have this code:

<?php
if ($quantity == 0){
$prd_name = " ";
$colors = " ";
$sizes = " ";
$quantity = " ";
$price = " ";
$TIP = " ";
$TPA = " ";
$cost = " ";
$amount = " ";
$query ="DELETE FROM orders WHERE quantity='0'";
}
?>

But it still makes a table row entry.

What I am trying to do is when the inputed number of quantity is 0 then the table row will be deleted. Please bear with me for I'm new in php and mySQL coding.

1
  • 2
    just assigning some sql-looking text to a variable doesn't actually DO anything. you still need to execute that query, which means loading up a DB library. Try php.net/pdo or php.net/mysqli Commented Jul 31, 2012 at 5:38

3 Answers 3

1

You forgot to execute the query. It should be

$query = mysql_query("DELETE FROM orders WHERE quantity='0'");
Sign up to request clarification or add additional context in comments.

Comments

0

Once run the query by removing Quotes to 0 If it's a number

<?php
    if($quantity==0)
     {
       $query = "DELETE FROM orders WHERE quantity = 0 ";
       mysql_query($query);
      }
 ?>

2 Comments

thanks. it works now. however, the previous quantity number is still reflected on the table.
@Ruri: I'm glad that I was able to help.
0
<?php
    if($quantity==0)
     {
       $query="Delete from orders where quantity=0";
       mysql_query($query);
      }
 ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.