i fetch two table result in one query. now i have in each table one row with name = userid. when i print id of table one, this not worked and printed id of table two . in i.e i select * from product and then voteid,userid form voteproduct where userid = $userid ; now i need print userid from product table but my result print userid from voteproduct . how to fix this ? thanks
my code :
$sql = 'SELECT * FROM ' . PREFIX . '_product,' . PREFIX . '_voteproduct WHERE ' . PREFIX . '_voteproduct.voteid = ' . PREFIX . '_product.id AND ' . PREFIX . '_voteproduct.userid = "' . $userid . '" ORDER BY name ' . $pages->limit .' ';
$db->query($sql) or error ('ERROR', mysql_error ());
$result = $db->query ( $sql );
if($db->numrows($result)>0){
while ($row = $db->fetcharray($result))
{
echo $row['userid']; // PROBELM THIS PRINTED USERID FROM VOTEPRODUCT I NEED PRINT USER ID FROM PRODUCT
}
EDIT : If I selected * from my product table, realy i need to all. ( name, price, date, category, …)
You can select each userid with
ASin order to use them separately like belowAnd use ;