Hey everyone I am using Pagination to display a query and I cannot figure out how to get it to print two rows then create a new page/
My code is:
<div class="pagination">
<?php
$host = "localhost";
$user = "user";
$pass = "pass";
$db = "cygnet_creativeink_site";
mysql_connect($host,$user,$pass) or die("ERROR:".mysql_error());
mysql_select_db($db) or die("ERROR DB:".mysql_error());
max = 8; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
if(isset($_GET['act']) && $_GET['act'] == "view")
{
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM photos WHERE id = '$id'");
while($r = mysql_fetch_array($sql))
{
$title = $r['Caption'];
$photo = $r['Photo'];
echo "<div><p>$title</p><p>$photo</p></div>";
}
}else{
//view all the news articles in rows
$sql = mysql_query("SELECT * FROM photos LIMIT ".$limits.",$max") or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM photos WHERE Gallery='logo'"),0);
//the total number of pages (calculated result), math stuff...
$totalpages = ceil($totalres / $max);
//the table
echo "<center><table border='0'><tr>";
while($r = mysql_fetch_array($sql))
{
$id = $r['id'];
$caption = $r['Caption'];
$photo = $r['Photo'];
echo "<td><div id='clipped'><a class='thumbs' href='images/photos/$photo' rel='lightbox[photos]' title='$caption'><img src='images/photos/$photo' border='1' width='70' height='100' style='opacity:1;filter:alpha(opacity=100)' onmouseover='this.style.opacity=0.5;this.filters.alpha.opacity=50' onmouseout='this.style.opacity=1;this.filters.alpha.opacity=100'></a></div></td>";
}
//close up the table
echo "</tr></table></center><p> </p>";
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo "<a href='logo.php?p=$i'>$i</a>|";
}
}
?>
</div>
This works great and it displays 8 entries as I have bolded. Except really what I want is 16 with 2 rows of 8.
Any suggestions of how to do this?
I have this code but I cannot seem to get it to work in my Pagination example:
<?php
for($i = 0; $i<$photos; $i++) {
$row = mysql_fetch_array($photoquery);
if(is_int($i/8)) {
print "</tr><td>PICTURE</td>";
}else{
print "<td>PICTURE</td>";
}
}
?>
Thanks for the help in advance!