Jump to content

gallery array problem


mofm

Recommended Posts

Im makeing a image gallery and im using an array to organise all my data  i want each indervidual album to go acroos the mage like this :

 

 

Album                                  album2

album image                    album image

album description              ablumb decription

 

 

etc etc ...  i only want 4 to show on any one row

 

Well hers my code and it only returns 1 row (4) albums when there is 7 in the database:

 

 

<table width="650" border="0">


<?php 
require '../includes/functions.php';
require '../includes/connect.php';
require '../includes/settings.php';

session_start();
/************************************************************
   Adjust the headers...
************************************************************/
header("Expires: Thu, 17 May 2001 10:17:17 GMT");    // Date in the past
  	header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");                          // HTTP/1.0
$album_id="";
if(empty($album_id))
{
$albums_query = "SELECT * FROM albums";
if($albums_result=mysql_query($albums_query))
{
	$counter=0;
	$albums=array();
	$set=0;
	while($albums_array=mysql_fetch_array($albums_result))
		{
			if ($counter%4==0 && !$counter==0)
				{
					$set++;
				}
			$albums[$set][$counter][0]=$albums_array['name'];
			$albums[$set][$counter][1]=$albums_array['description'];
			$albums[$set][$counter][2]=$albums_array['userid'];
			$albums[$set][$counter][3]=$albums_array['image'];
			$albums[$set][$counter][4]=$albums_array['user'];
			$albums[$set][$counter][5]=$albums_array['date'];
			$albums[$set][$counter][6]=$albums_array['id'];
			$counter++;
		}



$setcount=0;

while ($setcount<=$set)
	{

	$counter2=0;
	$rowcounter=0;
		while ($rowcounter<7)
		{

			while($counter2<4)
			{
			echo "<td colspan=\"3\">".$albums[$setcount][$counter2][$rowcounter]."</td>";
			$counter2++;
			}
		echo"</tr><tr>";
		$rowcounter++;
		$counter2=0;

		}

	$setcount++;
	}
}else{
//sqlerror
}
}

?>
</table>

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.