How can I compare two variable to an id table value in a query?
switch($_GET["action"])
{
case "add_item":
{
AddItem($_GET["ids"], $_GET["qty"]);
ShowCart();
break;
}
default:
{
ShowCart();
}
function AddItem($itemId, $qty){
$result = mysql_query("SELECT COUNT(*) FROM cart WHERE cookieId = '" . GetCartId() . "' AND id = $itemId");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
Can you see the AddItem Switch and case function I want to add $_POST["idc"] jus开发者_C百科t like below.
AddItem($_GET["ids"], $_POST["idc"], $_GET["qty"]);
Then in the function AddItem below the AddItem function inside the Switch function I will need to add another argument since there are three inside the Switch function. $itemId, $itemIdII and $qty
function AddItem($itemId, $itemIdII, $qty){
}
Notice that I have added $itemIdII to the AddItem function since I have added ,$_POST["idc"] in the Switch function.
Now the question
How can I compare $itemId and $itemIdII to the id in the query? Right now its like
AND id=$itemId
But how could I add $itemIdII to the query to compare it.
AND id=$itemId OR $itemIdII
Thanks!
AND id IN ($itemId, $itemIdII)
or
AND (id=$itemId OR id=$itemIdII)
精彩评论