Determine The End Of The Database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Determine The End Of The Database

Post by icesolid »

How do you determine the end of a MySQL database?

I want an action to occur once the end of the database is reached
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

end of the database? Do you mean the end of the query results?

:?
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Here's What I Have

Post by icesolid »

Heres what I have:

Code: Select all

<?php
$limit = "20";
$result = mysql_query("SELECT * FROM statistics ORDER BY id DESC LIMIT $offset,$limit");

if(mysql_num_rows($result) == $row["id"]) {
// what to display here
} else {
// what to display here
}
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

normally, processing of a result set is done with a loop.

Code: Select all

<?php
$limit = "20";
$result = mysql_query("SELECT * FROM statistics ORDER BY id DESC LIMIT $offset,$limit");

while($row = mysql_fetch_assoc($result)) {
// code here is for stuff during each result of the result set
}
// you'll be here immediately after the last result is processed from the result set

?>
Post Reply