Sid,
Thanks for your help.
Though I am still having trouble. When I query my DB I end up with a column of 6 images in one cell so I end up with my 2 row 3 column table containing 36 images when there should be 6 images. The reason I get 6 images per cell is because I have an offset script for multiple pages.
Here is an example of what I have for a script.... maybe someone has an answer?
Thanks in advance
mGee
<?php
// offset script
$limit = 6; // rows to return
$numresults = mysql_query(
"SELECT * FROM table ORDER BY last Asc");
if (!$numresults) {
echo("<p>Error performing query: " .
mysql_error() . "</p>");
exit();
}
$numrows = mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset = 0;
}
print "<table width='100%'>";
for ($i = 0; $i < 2; $i++) { //rows
print "<tr>";
for ($j = 0; $j < 3; $j++) { //cols
print "<td align='center'>";
//SELECT THE PICTURE DATA FROM THE DB
// get results
$result = mysql_query(
"SELECT * " .
"FROM table ORDER BY last Asc LIMIT $offset");
if (!$result) {
echo("<p>Error performing query: " .
mysql_error() . "</p>");
exit();
}
// now you can display the results returned
while ( $data = mysql_fetch_array($result) ) {
// include code to display results as you see fit
$ID = $data["id"];
$Imagefile = $data["imagefilepath"];
$Alttext = $data["alttext"];
$First = $data["first"];
$Last = $data["last"];
$Location = $data["location"];
echo("<a href='index.php?content=profile&id=$zpID'>" .
"<img src='images/thumbnails/$type/$Imagefile' border=0>" .
"</a><br>$First<br>$Last<br>");
}
print "</td>";
}
print "</tr>";
}
print "</table>";
print "<br>";
print "<table width='100%'>";
print "<tr>";
print "<td align='center'>";
// next we need to do the links to other results
if ($offset>=1) { // bypass PREV link if offset is 0
$prevoffset = $offset-6;
print "<a href=\"$PHP_SELF?content=$type&offset=$prevoffset\">PREV</a> \n";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?content=$type&offset=$newoffset\">$i</a> \n";
}
// check to see if last page
if (!(($offset/$limit)==$pages) && $pages !=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?content=$type&offset=$newoffset\">NEXT</a>\n";
}
print "</td>";
print "</tr>";
print "</table>";
?>