Hey everyone, I am trying to display the result set of an array that I got from mysql_fetch_array, like this:
while($imageinfo_array = mysql_fetch_array( $imageinfo_query ))
<?php echo $imageinfo_array['IMAGE_NAME'] ; ?>
<?php echo $imageinfo_array['CATEGORY_TYPE'] ; ?>
etc.
But there is sometimes more than one CATEGORY_TYPE associated with an IMAGE_FILE. I am just looking to print out the image name and then the corresponding categories associated with them, without reprinting the image again.
I'm pretty sure this is common, but I've been at a loss as to an easy way to do it.
Thanks,
JW
Outputting a mysql_fetch_array result
Moderator: General Moderators
-
jwburnside
- Forum Newbie
- Posts: 1
- Joined: Tue Apr 27, 2010 11:36 am
Re: Outputting a mysql_fetch_array result
What does your query look like?
Re: Outputting a mysql_fetch_array result
I'm guessing your query must be something likejwburnside wrote:Hey everyone, I am trying to display the result set of an array that I got from mysql_fetch_array, like this:etc.Code: Select all
while($imageinfo_array = mysql_fetch_array( $imageinfo_query )) <?php echo $imageinfo_array['IMAGE_NAME'] ; ?> <?php echo $imageinfo_array['CATEGORY_TYPE'] ; ?>
But there is sometimes more than one CATEGORY_TYPE associated with an IMAGE_FILE. I am just looking to print out the image name and then the corresponding categories associated with them, without reprinting the image again.
I'm pretty sure this is common, but I've been at a loss as to an easy way to do it.
Thanks,
JW
Code: Select all
SELECT * FROM table WHERE image_name='image name' Code: Select all
<?php echo $imageinfo_array['CATEGORY_TYPE'] ; ?>You may want to first run a query to select all the distinct image names, store them into an array, and then use a foreach statement to run a mysql query for each individual picture to select all its categories. The other way I would recommend would be to maybe make a category column in the table, and then store all the categories using a comma between each. Then you could just get the value of category, and use explode to break that up individually if you need to.