I've created a script that reads a sorted mysql query and outputs specific
results into text files defined by the start and limit of mysql. The
database holds 178 records. I want to start my output on #9 with 10
records per page. Should leave me with 17 equal pages right?
$count = 178
$start = 8; (Mysql starts at record 0)
$per_page = 10;
$page = 1;
while ($start <= $count) {
$fp = fopen("Page$page.txt", "w");
mysql_connect ($host, $user, $pass);
mysql_select_db ($database);
$result = mysql_query ("SELECT * FROM internal_listings, agents WHERE
internal_listings.agent = agents.name AND category = 'Standard' ORDER by
area,price LIMIT $start, $per_page");
if ($row = mysql_fetch_array($result)) {
do {
##misc ouput to file $fp for 10 records in query
}
while($row = mysql_fetch_array($result));
}
fclose($fp);
mysql_close();
$start = $start + $per_page;
$page++;
}
When I run the script outlined above I get 18 pages. Page number 18 is
blank as it should be as there should be no more listings to output to a
text file but why is there a page number 18 to begin with? It should end
with page number 17.
Thanks in advance for any insight,
Ed
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php