gsencan Posted August 25, 2011 Share Posted August 25, 2011 <?php mysql_connect("AAA", "BBB"CCC") or die(mysql_error()); mysql_select_db("DDD") or die(mysql_error()); $result = mysql_query("SELECT * FROM image WHERE CATEGORY='SPORTS' ORDER BY DATE DESC") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo 'blablabla'; ?> Here i want to show 20 data from my database by newest time. DATE is a timestamp (current time )field in my database. so i think i have to use foreach statement but, what should i use when i want to show again 20 data in another page but now: newest from 20 to 40 or 40 to 60? I hope i put it out clear . Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted August 26, 2011 Share Posted August 26, 2011 search the forums for "pagination" you should get the full 1000 results. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted August 26, 2011 Share Posted August 26, 2011 Simple code to display data found from the database. http://phpsnips.com/snippet.php?id=94 Quote Link to comment Share on other sites More sharing options...
gsencan Posted August 26, 2011 Author Share Posted August 26, 2011 Ok ty. Quote Link to comment Share on other sites More sharing options...
gsencan Posted August 26, 2011 Author Share Posted August 26, 2011 I used this code it works for me. So it shows most recent 20 to 40 data(20 data per page). <?php mysql_connect("AAA", "BBB", "CCC") or die(mysql_error()); mysql_select_db("DDD") or die(mysql_error()); $result = mysql_query("SELECT * FROM mytable WHERE CATEGORY='SPORTS' ORDER BY DATE DESC LIMIT 20, 40") or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo 'blablabla'; } ?> Quote Link to comment 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.