Jump to content

Help with while loop


anthelo

Recommended Posts

Hello,

 

What im trying to do is show under each category some pictures...

 

I found this code and change it a little bit, but its still shows only one category and the images...

 

Any suggestions how im gonna change it to show all my category's?

 

<div id="PastProjects">Past Projects</div>
<?php 

$query = mysql_query("SELECT * FROM tbl_pastprojects");

$counter = 0;//Use this as a way to ID data as it comes in.

while($row = mysql_fetch_assoc($query))
{	
$catid[$counter] = $row['IssueId'];		
$catname[$counter] = $row['Title'];                
$Counter++;
}

$NumTimes = count($catid); //Establishing a number of times to run the second loop
for($i=0; $i<=$NumTimes; $i++)
{	
$query1 = mysql_query("SELECT * FROM tbl_pastprojects_entries WHERE IssueId = ".$catid[$i]."");

$c=0;//Another Counter for SubID's	
                while($row = mysql_fetch_assoc($query1))	
{				
	$subid[$i][$c] = $row['Id'];		
	$sname[$i][$c] = $row['Thumb'];                                
	$c++;	
}
}
//Now all of the Cats are stored in 2 Arrays(1 For name and 1 for ID) and SubCats are in 2 Multi Arrays(1 For name and 1 for ID)

///Generate Display
for($j=0; $j<$NumTimes; $j++)
{
echo("<div id='PastProjectstitle'>");
echo($catname[$j]);
echo("</div>");
//Establish Count for  sub cats
$NumCats = count($subid[$j]);//This counts the second dimension of the array (which is the num of sub categorys for that particular category)
echo("<div id='PastProjectsImages'>");
//Loop through each SubCat
for($k=0; $k<$NumCats; $k++)
{
	echo("<img src='".$sname[$j][$k]."' />");

}
	echo("</div>");

}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.