So looking at your example I have come up with the following: However when I add the 2 "auction" numbers that are returned from my second query to the order_2 database I still get results returned, when I should not be getting anything.
So order_2 has 12345, 67890, 13579 in the auction field.
The results returned from $auction_query are 12345, 67890, 13579. However when I run the code below I get 67890 as a result.
If I remove one or more rows from order_2 then I get the proper responce.
Please advise if possiable.
Thanks in advance.
@mysql_select_db($ORDER_DATABASE) or die("Unable to connect to the database");
$order_query = "SELECT auction FROM order_2";
$order_res=mysql_query($order_query) or die(mysql_error());
//$rez_db1 will contain all the Auctions from [order_2] (ex. 1,2,3,4)
$rez_db1 = '';
while ($sc = mysql_fetch_assoc($order_res)) $rez_db1.= "{$sc['auction']},";
mysql_free_result($order_res);
if (!empty($rez_db1)) $rez_db1 = substr($rez_db1,0,-1); /* final result */
else $rez_db1 = 0;
mysql_close();
mysql_connect (localhost, $USERNAME, $PASSWORD);
@mysql_select_db($AUCTION_DATABASE) or die("Unable to connect to the database");
$auction_query = "SELECT a.auction, a.winner, b.id FROM ";
$auction_query.= "winners a, auctions b ";
$auction_query.= "WHERE a.auction=b.id AND (b.closed=1 or b.closed=-1) ";
$auction_query.= "AND b.suspended=0 AND a.winner= $ID AND a.auction NOT IN ('{$rez_db1}')";
$auction_res=mysql_query($auction_query) or die("Unable to connect to the database");
// This should return all items that are not in order_2, auction table.
while ($sc = mysql_fetch_assoc($auction_res)) {
echo "<pre>",print_r($sc,1),"</pre>";
}mysql_free_result($auction_res);
mysql_close();