Page 1 of 1

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

Posted: Sun Apr 21, 2002 4:27 pm
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

Posted: Mon Apr 22, 2002 3:24 am
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 ?>">

Yes but...

Posted: Wed Apr 24, 2002 8:34 am
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?:(