Using a defined start point for the rows and an offset.
The script only returns 11 when I requested 12. I know I have more than 11. I tried the SELECT query in phpMyAdmin it works fine so it must be somehting to do with the way I'm using the code. I can't spot it. Can anybody have a read through and see if you can spot it?
Thanks
The script only returns 11 when I requested 12. I know I have more than 11. I tried the SELECT query in phpMyAdmin it works fine so it must be somehting to do with the way I'm using the code. I can't spot it. Can anybody have a read through and see if you can spot it?
Thanks
Code:
<?php
$dbh=mysql_connect ("computer", "database", "password")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dbname");
$lolimitbase = 0;
$offset = 12;
$lolimit = 1;
if ($pageno > 1) {
$lolimit = ($pageno -1 ) * $offset;
}
echo "$lolimit";
$query = "SELECT * FROM image_tb ORDER BY date_up DESC LIMIT $lolimit,$offset";
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$counter = 1;
while ($row = mysql_fetch_array($result))
{
$imgname = $row[img]name[/img];
$imgurl = $row[url];
$imglarge = $row[large_link];
$imgdate = $row[date_up];
if ($counter == 1) {
echo "<body bgcolor='#000000' text='#000000'>";
echo "<table width='650' border='0' cellpadding='1' cellspacing='10' bgcolor='#000000' bordercolor='#000000'>";
echo "<tr bordercolor='#000000'>";
}
// Normal code
echo "<td height='140' valign='middle' align='center' bgcolor='#FFFFFF'>";
echo "<div align='center'>";
echo "<a href='/$imglarge'";
echo "target='_blank'>";
echo "<img src='/$imgurl'";
echo "width='133'";
echo "height='100'";
echo "border='0'>";
echo "</a>";
echo "<br>";
echo "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'>$imgname</font>";
echo "</div>";
echo "</td>";
if ($counter == 4) {
echo "</tr>";
echo "<tr bordercolor='#999999'>";
}
if ($counter == 8) {
echo "</tr>";
echo "<tr bordercolor='#999999'>";
}
if ($counter == 12) {
echo "</tr>";
echo "</table>";
break;
}
$counter++;
}
echo "</tr>";
echo "</table>";
?>