Click to See Complete Forum and Search --> : Simple SQL statement problem


maximus99999
06-26-2007, 12:31 PM
$itemnames = "SELECT * FROM inventory INNER JOIN purchases ON inventory.id = purchases.item_id";
$itemnamesres = mysql_query($itemnames);
$useritems = "SELECT * FROM ".$itemnameres." WHERE session='".session_id()."'";
$useritemsres = mysql_query($useritems);
while($itemrow = mysql_fetch_assoc($useritemsres))
{
echo "<div align='center'>".$itemrow['name']."</div>";
}

Does anybody know the reason why this doesn't work?
The problem is when I want to use the result from the first statement.

bubbisthedog
06-26-2007, 01:45 PM
Please display the table structures of inventory and purchases.

maximus99999
06-26-2007, 05:44 PM
nvm, i got it fixed.

Should've just combined the sql statements instead of using 2 different ones.

mattyblah
06-28-2007, 12:09 AM
you're try to use a resource where a string was expected.