Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Order/limit By issue

Tags:

mysql

i have a problem with a script i'm creating. I am using the PHP/SQL Statement ORDER BY. I have a topsite where i use the script below

$sql = "SELECT * FROM topsites  WHERE categorie = '".$_GET['c']."' ORDER BY in DESC, out DESC LIMIT ".$perpage."";

And i need to know if there's a way i can create different pages, say first page is 1-50, second is 50-100

I have searched google for a solution to this question, but i can't seem to find anything.

like image 491
Simon Andersson Avatar asked Mar 12 '26 10:03

Simon Andersson


1 Answers

SELECT .... LIMIT CountToSkip, CountToSelect

The first page will be LIMIT 0,50, LIMIT 50,50 on the second, etc.

like image 134
RiaD Avatar answered Mar 15 '26 19:03

RiaD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!