OK
woah, what a mission for a beginer. Please don't laugh at my code (too hard

).
I've so far accomplisehd successfully these parts that bech100 suggested:
// Get the number of thumbnails that are in the Database
// Add 1 to the number of thumbnails until it is divisable by five
// Start the table
You can see them here:
Code: Select all
//Variables for the loops below
$monthlytotal = "0"; //This one holds the total number of entries for each month
$ShowMaxMonth = mysql_num_rows($content);
$ShowMax = mysql_num_rows($content);
// $x = 1; //This one used in the while loop for drawing the rows etc in the table
// Get the number of thumbnails that are in the Database
for ($y=1; $y<=$ShowMaxMonth; $y++)
{
$year = $Xcontent["year"];
$month = $Xcontent["month"];
//Only load images etc from the appropriate year
if ($year == "2001")
{
//Only load images etc from the appropriate month
if ($month == "12")
{
$monthlytotal = $monthlytotal + "1";
print "$monthlytotal, ";
}
}
$Xcontent = mysql_fetch_array($content);
}
//Is monthlytotal divisible by 4? If not, make it!!!
$mod = $monthlytotal % 4;
if ($mod != 0)
{
$monthlytotal += (4 - $mod);
echo "<br>rounded up to $monthlytotal";
}
//Start the table to draw the thumbnails into
print "<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="$sBColor">";
print "<tr>";
OK, so they work (it was fun and a challenge, I'll clean it up more later).
Now I'm moving onto the bit where I was suggested to do these things:
// While $x is less than the number of thumnails and $x is not divisable by 5, output the <td> and thumbnails
// When $x is divisable by 5, start new row
// Repeat previous
// When $x equals actual number of thumnails, output enough cells to complete the table
// Finish table
I've got the whole code here, but am having real trouble with it, so far I'm only trying to get the new row to start at (4, not 5). It's just not working. I think I'm temporarily overstressing my artist braincells...
Please if you ahve time, look through my code and perhaps point to what I might be doing wrong? I'd REALLY appreciate it
Thanks heaps,
Rob
Code: Select all
<?
$connection = mysql_connect($dbhost, $dbusername, $dbpassword);
$content = mysql_db_query($dbname, "SELECT * FROM archives ORDER BY id ASC");
$Xcontent = mysql_fetch_array($content);
//Variables for the loops below
$monthlytotal = "0"; //This one holds the total number of entries for each month
$ShowMaxMonth = mysql_num_rows($content);
$ShowMax = mysql_num_rows($content);
$x = 1; //This one used in the while loop for drawing the rows etc in the table
// Get the number of thumbnails that are in the Database
for ($y=1; $y<=$ShowMaxMonth; $y++)
{
$year = $Xcontent["year"];
$month = $Xcontent["month"];
//Only load images etc from the appropriate year
if ($year == "2001")
{
//Only load images etc from the appropriate month
if ($month == "12")
{
$monthlytotal = $monthlytotal + "1";
print "$monthlytotal, ";
}
}
$Xcontent = mysql_fetch_array($content);
}
//Is monthlytotal divisible by 4? If not, make it!!!
$mod = $monthlytotal % 4;
if ($mod != 0)
{
$monthlytotal += (4 - $mod);
echo "<br>rounded up to $monthlytotal";
}
//Start the table to draw the thumbnails into
print "<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="$sBColor">";
print "<tr>";
$content = mysql_db_query($dbname, "SELECT * FROM archives ORDER BY id ASC");
$Xcontent = mysql_fetch_array($content);
$ShowMax = mysql_num_rows($content);
for ($y=1; $y<=$ShowMax; $y++)
{
$year = $Xcontent["year"];
$month = $Xcontent["month"];
//Only load images etc from the appropriate year
if ($year == "2001")
{
//Only load images etc from the appropriate month
if ($month == "12")
{
for ($x=1; $x<=$monthlytotal; $x++)
{
// While $x is less than the number of thumnails and $x is not divisable by 4, output the <td> and thumbnails
while ($x < $monthlytotal and ($x % 4) != 0)
{
print "<td>";
print "month - $month";
print "</td>";
}
// When $x is divisable by 4, start new row
if ($x = ($x % 4) != 0)
{
print "<tr>";
}
} //end for loop
}
}
print "</tr>";
$Xcontent = mysql_fetch_array($content);
}
print "</table>";
mysql_free_result($content);
?>