1

I want to update multiple itemIDs with the same status. I know that this is imposible with mysql_query but I can't figure out a way to get this working.

     $upd = "UPDATE booking SET status='$status' WHERE itemID='$itemID', '$itemID2'";
     $retval = mysql_query($upd, $con);

Note: The itemIDs are inputted by user in prev page like this

     $itemID= $_POST["itemID"];
     $itemID2= $_POST["itemID2"];
1
  • where itemid in (itemid1, itemid2) will do the trick. Commented Jan 12, 2015 at 9:36

2 Answers 2

2

Use IN clause as like:

WHERE itemId in ('$itemID', '$itemID2');

instead of WHERE itemID='$itemID', '$itemID2'

Sign up to request clarification or add additional context in comments.

1 Comment

Works like a charm and it was a so easy fix, thanks1 :D
1

Use IN

$upd = "UPDATE booking SET status='$status' WHERE itemID IN ('$itemID', '$itemID2')";

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.