Hi,
I've got a database that returns results and limits the number of results to five a page with nav buttons at the bottom. What I want to know is how can I display my results in columns but still keep te nav e.g.
R1 R2 R3 R4 R5
R6 R7 R8 R9 R10
<Nav Bar>
Here is the code I have for my rows limit.
include('../generic/connect.php');
$Link=mysql_connect($Host, $User, $Password);
// how many rows to show per page
$rowsPerPage = 5;
// 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 * FROM photo_pic WHERE pic_album=('$album') LIMIT $offset, $rowsPerPage";
$Result=mysql_db_query ($DBName, $Query, $Link);
$count=mysql_num_rows($Result);
print("<p align=\"center\"><font face=\"Arial\" size=\"16pt\"><b>$album Album</b></font></p>");
while ($Row = mysql_fetch_array ($Result)){
print("<p align=\"center\">");
print ("<TABLE BORDER=0 WIDTH=\"75%\" CELLSPACING=2 CELLPADDING=0 ALIGN=CENTER>\n");
print("<TR ALIGN=CENTER VALIGN=TOP>\n");
print("<TD ALIGN=CENTER VALIGN=TOP width=\"100%\"><a href=\"javascript:popUp('show_large.php?pic=$Row[pic_id]&name=$Row[pic_fname]')\"><img src=\"images/$Row[pic_fname]\" width=\"150\" height=\"100\" border=\"0\"></img></a><br><font face=\"Arial\" size=\"2pt\"><a href=\"mailto:photo_album@thewalluk.com?Subject=Report Picture $Row[pic_id]\">Report this picture</a></font></TD>\n");
print("</TR>\n");
}
// how many rows we have in database
$query = "SELECT COUNT(*) AS numrows FROM photo_pic WHERE pic_album=('$album')";
$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?
$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?album=$album&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;
$prev = " <a href=\"$self?album=$album&page=$page\">[Prev]</a> ";
$first = " <a href=\"$self?album=$album&page=1\">[First Page]</a> ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?album=$album&page=$page\">[Next]</a> ";
$last = " <a href=\"$self?album=$album&page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
mysql_close ($Link);
print("</TABLE>\n");
// print the navigation link
print(" <p align=\"center\"><font face=\"Arial\">Showing page $pageNum</font></p>");
echo ("<p align=\"center\"><font face=\"Arial\">$first $prev $nav $next $last</font></p>");
print("</p>");
Please if anyone can help me.