displaying certain no. of records using PHP-SQL 7.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ashish_cal2
Forum Newbie
Posts: 7
Joined: Sun Apr 21, 2002 2:20 pm
Contact:

displaying certain no. of records using PHP-SQL 7.

Post by ashish_cal2 »

hello guys

i am retrieving all the record from the table & want to display 5 record at a time with next & previous buttons.I am using PHP & Ms-SQL sever 7.0.How should i go about it.

Help plzzzzzzz

thanx in advance
Bye
nahp
Forum Newbie
Posts: 7
Joined: Mon Apr 22, 2002 3:24 am

Post by nahp »

by doing using the limit options of a select query you should get what you re looking for :

select * from t_table limit offset, number_of_rows

in your case :

$query = "select * from t_table limit " . $offset . " , 5 " ;

and with a link change the offset value :

<a href="<?= $PHP_SELF ?>?offset=<?= $offset + 5 ?>">
User avatar
Geokos
Forum Newbie
Posts: 1
Joined: Wed Apr 24, 2002 8:34 am

Yes but...

Post by Geokos »

As you say I wrote:

$result = mysql_query( "SELECT * FROM news ORDER BY id DESC LIMIT 5" );

but it gives me the first 5 WITHOUT showing the very first one!
What's the problem?:(
Post Reply