php - How do i get data from one table according to an id field in another? -
so far loop pulls item images items table using method created , positions them wonderfully.
now trying use $linv['item_id']
find item id's of items in items table, , pull data table use between <span>
tags (creating tooltip).
i'm confused sql calls now.
<?php $idata = mysql_query("select * `items` `item_id`='".$linv['item_id']."'"); while($linv = mysql_fetch_array($inv)){ $idata = mysql_fetch_array($itemdata); echo "<a class='tooltips' href='#'><img id='bagicons' src='".getiimage($linv['item_id'])."' /> <span> ".$itemdata['item_name']." </span></a>" ; } ?> </div> <div id="spacer"> </div> <?php echo "<div id='char'>".createavatar($_session['uid'])."</div>"; include("footer.php"); ?>
change
<?php $idata = mysql_query("select * `items` `item_id`='".$linv['item_id']."'"); while($linv = mysql_fetch_array($inv)){ $idata = mysql_fetch_array($itemdata); echo "<a class='tooltips' href='#'><img id='bagicons' src='".getiimage($linv['item_id'])."' /> <span> ".$itemdata['item_name']." </span></a>" ; } ?>
to
<?php while($linv = mysql_fetch_array($inv)) { $idata_result_set = mysql_query("select * `items` `item_id`='".$linv['item_id']."'"); if(mysql_num_rows($idata_result_set) == 0) continue; $idata = mysql_fetch_array($idata_result_set); echo "<a class='tooltips' href='#'><img id='bagicons' src='".getiimage($linv['item_id'])."' /> <span> ".$idata['item_name']." </span></a>" ; } ?>
Comments
Post a Comment