Displaying 2 images of each of the latest 5 category's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blade_922
Forum Contributor
Posts: 132
Joined: Wed Jul 12, 2006 4:57 pm

Displaying 2 images of each of the latest 5 category's

Post by blade_922 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hey guys,

what im trying to do is display 2 images of the latest 5 games that have been added to my site.

Each image is connected to a game and the image has its own cat_id(game id) and every image has its own unique id


for example

Image 1, 2, 3, have cat_id 10
Image 4, 5, 6, have cat_id 11
Image 7, 8, 9, have cat_id 12


Im trying to display it in a table so, the 2 images are side by side on there own row. then the next cat_id is on the next row showing 2 of its images and so on

The below code manages to display the latest 10 images all on seperate rows and thats it. I cant seem to work out how to show the latest 2 images of the latest 5 cat_id so there are 5 rows with 2 images of a different category on each.


It sounds complex eh 

So can anybody help me out?

Regards

Code: Select all

//===================================================
// DISPLAY MEDIA INDEX
//-----------------------------------------------------------------

if (!$_REQUEST[action]) {

//===================================================
// 	DISPLAY CATEGORIES
//-----------------------------------------------------------------
	$divtitle = "$lang_categories";
	include "templates/$skin/divtitle.php";
//===================================================

echo "	<img src=\"images/spacer2.gif\">
	<table align=\"center\" width=\"98%\" $tablereg>
  	<tr>
		<td width=\"75%\" $tdreg3><SPAN class=\"headertitle\">&nbsp;$lang_category</SPAN></td>
			</tr>\n";

$latestfiles = mysql_query("SELECT * from ccms_screenshots ORDER BY id desc limit 10");

	while($row = mysql_fetch_array($latestfiles)) {


echo "	<tr>
		<td width=\"75%\" $tdreg><SPAN class=\"content\"><img src=\"images/folder.gif\" align=\"absmiddle\" hspace=\"4\" /><img border=\"0\" src=\"thumbnailer.php?image=" .$row['url'] ."&type=Media\" border=\"0\">$row[title]</SPAN></td>
	</tr>\n";


	}


echo "	</table>
	<img src=\"images/spacer2.gif\">\n";

}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
blade_922
Forum Contributor
Posts: 132
Joined: Wed Jul 12, 2006 4:57 pm

Post by blade_922 »

never mind i have worked it out now using SELECT DISTINCT
Post Reply