Hi, I just noticed that my queries are coming up one short. Can someone help me figure out why? I say I would like to limit the query to ten results, but I only get nine (9) returned.
Here is the code:
<p>These are the 25 all-time great books on golf. Click the links below to read their reviews:</p>
<ul>
<?php
if(!isset($start)) $start = 0;
// DB conn info
require ("../inc/db.inc.php");
// "connecting2_db()" function on db.inc.php
$my_db = connecting2_db();
// Select proper table, limit 10.
$sql = "SELECT id,title FROM books ORDER BY id ASC LIMIT " . $start . ", 10";
// Connect or die and tell us
$result = mysql_query($sql,$my_db) or db_mysql_die();
$row = mysql_fetch_array($result);
// While our query is true, do this:
while ($row = mysql_fetch_array($result)){
$id = $row["id"];
$title = $row["title"];
echo "<li><a href='details.php?id=$id'>$title</a></li>\n";
}
?>
</ul>
<br>
<p><?php
$query = "SELECT count(*) as count FROM books";
$result = mysql_query($query,$my_db);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<img src='../images/sitenav/black_arrow_left.gif' alt='Previous' width='6' height='12' border='0'> <a href='" . $PHP_SELF . "?start=" . ($start - 10) . "'>Previous</a> \n";
if($numrows > ($start + 10))
echo " <a href='" . $PHP_SELF . "?start=" . ($start + 10) . "'>Next</a> <img src='../images/sitenav/black_arrow.gif' alt='Next' width='6' height='12' border='0'>\n";
mysql_close(); // end SQL session
?></p>