|----- Original Message ----- |From: <[EMAIL PROTECTED]> |To: <[EMAIL PROTECTED]> |Sent: Wednesday, July 02, 2003 9:23 AM |Subject: [PHP] PHP and Mysql Limit | | |> |> 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"); [snip]
On Jul 2, 2003, "Chris Sherwood" claimed that: |It looks like your adding 10 to 8 thus getting 18... of course I maybe |looking at this wrong | Then, once you've done it enough times, $start = $count = 178. [code] while ($start <= $count) { // when $start = $count = 178, you won't retrive any data [/code] I would probably also move as much of the mysql_connect as possible to outside the loop. It only needs to be done once. -- Registered Linux user #304026. "lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import" Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php