Cultureshock Posted November 11, 2009 Share Posted November 11, 2009 (Basically this is for paginating data)... Say I have a list of data 10 rows long, but I only want to show data rows 3-8 in my while statement. I use ?limit=5 (aka $limit = $_GET['limit']; ) to set the mysql query LIMIT $limit. But obviously this code shows rows 1-5. If I use ?page=3&limit=5 (aka $limit = $_GET['limit'];$page = $_GET['page']; ), how would I print out only data rows starting at the third row? Is this something in the query or php? Quote Link to comment https://forums.phpfreaks.com/topic/181182-how-to-echo-mysql-rows-at-certian-point/ Share on other sites More sharing options...
Raider Posted November 11, 2009 Share Posted November 11, 2009 I'm not sure if I correctly understand, but here goes. When you use LIMIT with MySQL queries, you can put one or two numbers afterwards. The first number is the row from which it should start, and the second number is the amount of rows it should count from the starting point (first number). Example: mysql_query("SELECT * FROM my_table LIMIT 5,5"); That will select all columns from 'my_table'. However, it will start at row 5 and take 5 rows from there, i.e., it will take rows 6, 7, 8, 9, 10. mysql_query("SELECT * FROM my_table LIMIT 0,5"); That will get rows 1, 2, 3, 4, 5. Quote Link to comment https://forums.phpfreaks.com/topic/181182-how-to-echo-mysql-rows-at-certian-point/#findComment-955875 Share on other sites More sharing options...
Cultureshock Posted November 11, 2009 Author Share Posted November 11, 2009 Thanks! That's exactly what I was looking for. How did I not learn that anywhere? X.X Quote Link to comment https://forums.phpfreaks.com/topic/181182-how-to-echo-mysql-rows-at-certian-point/#findComment-955878 Share on other sites More sharing options...
Raider Posted November 11, 2009 Share Posted November 11, 2009 You're welcome, glad I could help Quote Link to comment https://forums.phpfreaks.com/topic/181182-how-to-echo-mysql-rows-at-certian-point/#findComment-955879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.