Hi Board,
I have still been trying to create my gallery of thumbs that open in the same page to the right of the thumbs, but don't want to use tables.
Can i tweak my code here to output the thumbs, 5 per row, and 2 rows per page, [total of 10per page] , into an unordered list?
I have been successful with the pagination thanks to Matt Kindig's previous post, but am stuck on how to output the thumbs into <ul> tags.
any suggestions would be a relief,
thanks
k
<?php
include "dbconnect.php";
// how many rows to show per page
$rowsPerPage = 2;
// by default we show first page
$pageNum = 1;
// if $GET['page'] defined, use it as page number
if(isset($GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT menimage FROM men LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
// print the random numbers
// show the thumbnails in galleries
while($row = mysql_fetch_array($result))
{
//echo $row['menimage'] . '<br>';
//this will
//echo "<td><a href='images/men/{$row['menimage']}'
//<img src ='images/men/{$row['menimage']}' border='5'
//width='100' height='100'></a></td>\n";
//show all data from database with images
//$accid=$row['menid'];
//$mendescription=$row['mendescr'];
$menimage=$row['menimage'];
//$imageheight=$row['imageheight'];
//$imagewidth=$row['imagewidth'];
echo "<ul>";
//echo "<tr><td valign=βtopβ>\n";
//echo "<td>{$row['menid']}</td>\n";
//echo "<td>{$row['mendescr']}</td>\n";
echo "<li>{$row['menimage']}";
echo "<a href='images/men/{$row['menimage']}'
border='3' alt='images joeyd'>
<img src ='images/men/thumb/{$row['menimage']}' border='1'
width='57' height='75'></a>";
//echo '<img src="images/men/'.$images[$i]['menimage'].'" border="2" width="150" height="150">';
}
echo '<br>';
// how many rows we have in database
// image database has fieldname of menimage, accimage, menimage
$query = "SELECT COUNT(menimage) AS numrows FROM men";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
//The mathematical function ceil() is used to round up the value of $numrows/$rowsPerPage.
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"$self?page=$page\">$page</a>";
}
}
// creating previous and next link
// plus the link to go straight to
// the first and last page
if ($pageNum > 1)
{
$page = $pageNum - 1;
// i've put [Prev] here but we can change this to joeyD home or something after.
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
//same here - this could read 1st Page ro something.
$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // don't print the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // don't print the last page link
}
// print the navigation link
echo $first . $prev . $nav . $next . $last;
// and close the database connection here
?>