I have some code that adds 14 images to a page and then gives next previous. My question is how do I modify it to have 5 images per row with the name of the image underneath the image? I know it has to do with the table layout but I am not sure how to do it. Here is my code. Any suggestions would be helpful. By the way, I found this code on this website. Thanks for the help so far
$limit = 14;
$con = mysql_connect("$server","$userid","$pass") or die ("Huh? What Server");
$db = mysql_select_db("$database",$con) or die("I said WHAT database");
if (empty($offset) || $offset < 0) {
$offset=0;
}
if (empty($index)) $index=0; / This is to count the line index of the results /
$getrows = mysql_query("select from $dbtable", $con);
$numrows=mysql_num_rows($getrows);
$path ="/Images/TShirts/";
$type =".gif";
$query = mysql_query("select from $dbtable limit $offset,$limit", $con);
while ($result=mysql_fetch_array($query)){
$index++; / Increment the line index by 1 /
echo ("<table align=center width=60% border=1>
<tr>
<td>
<img border=1 height=166 width=123 alt=$result[image] src=\"$path".$result[image]."$type"."\"></td>
</tr>
");
}
echo ("</table>");
if ($numrows <= $limit) {
}
else {
if ($offset!=0) {
$prevoffset=$offset-$limit;
echo "<br><a onMouseOver=\"window.status='Previous $limit Results'; return true\"; href=\"$PHP_SELF?offset=$prevoffset&index=$prevoffset\"><B>[Previous]</B></a> ";
}
else echo "<b><font color=666666>[Previous]</font></b> ";
// Calculate total number of pages in result
$pages = intval($numrows/$limit);
// $pages now contains total number of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// Now loop through the pages to create numbered links
// ex. 1 2 3 4 5 NEXT
for ($i=1;$i<=$pages;$i++) {
// Check if on current page
if (($offset/$limit) == ($i-1)) {
// $i is equal to current page, so don't display a link
echo " <b><font color=666666>$i</font></b> ";
} else {
// $i is NOT the current page, so display a link to page $i
$newoffset=$limit*($i-1);
echo " <a onMouseOver=\"window.status='Page $i Results'; return true\"; href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\"><B>$i</B></a> \n";
}
}
// Check to see if current page is last page
if (!((($offset/$limit)+1)==$pages) && $pages!=1) {
// Not on the last page yet, so display a NEXT Link
$newoffset=$offset+$limit;
echo " <a onMouseOver=\"window.status='Next $limit Results'; return true\"; href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\"><B>[Next]</B></a><p>\n";
} / Im doing the same thing here as i did in the [Previous] above /
else echo " <b><font color=666666>[Next]</font></b>";
}
mysql_close($con);
?>