Jump to content
xisto Community
Sign in to follow this  
eskimmer

Problem With A Mysql Join Problem with a mysql join

Recommended Posts

Hello

I am trying to write a script whereby I can pull an image out of one database table and display it in relation to its category_id in another table. I am using a my_sql join function that is joining the tables correctly, however it only shows the one same image from the top field of those combined rows on every single page. I need it display the image according to its category_id for that particular page. I am thinking I need to set variables to represent those specific rows but I'm not sure how to do that.

Here is my code

{$result = mysql_query("SELECTplacing_item_bid.category_id, category_master.icon_1FROMschool_auction.category_master, school_auction.placing_item_bidWHEREplacing_item_bid.category_id=category_master.category_id andcategory_master.icon_1=category_master.icon_1");$row = mysql_fetch_array( $result );$img=$row['icon_1'];list($width, $height, $type, $attr) = getimagesize("images/$img");$h=$height;$w=$width;if($h>200){$nh=200;$nw=($w/$h)*$nh;$h=$nh;$w=$nw;}if($w>160){$nw=160;$nh=($h/$w)*$nw;$h=$nh;$w=$nw;}?><img name="runimg" src="images/<? echo $row['icon_1'];?>"border=1 width=<?= $w; ?> height=<?=$h?> >

Notice from Plenoptic:
Xisto ReadMe Make sure that all code is put into the proper BBCode Tags.

Edited by Plenoptic (see edit history)

Share this post


Link to post
Share on other sites

Should it display all the results from the query? Maybe you should create a loop statement so that it will display ALL results instead of just displaying the last result row.

Share this post


Link to post
Share on other sites

Something like this perhaps (assuming your query is correct)..

$result = mysql_query("SELECT placing_item_bid.category_id, category_master.icon_1FROM school_auction.category_master,school_auction.placing_item_bidWHERE placing_item_bid.category_id=category_master.category_id and category_master.icon_1=category_master.icon_1");while($row=mysql_fetch_row($result)){	$img=$row['icon_1'];			echo '<img name="runimg" src="images/'. $img .'">';}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.