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 . Link to comment https://forums.phpfreaks.com/topic/245716-mysql-foreach/ 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. Link to comment https://forums.phpfreaks.com/topic/245716-mysql-foreach/#findComment-1262179 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 Link to comment https://forums.phpfreaks.com/topic/245716-mysql-foreach/#findComment-1262326 Share on other sites More sharing options...
gsencan Posted August 26, 2011 Author Share Posted August 26, 2011 Ok ty. Link to comment https://forums.phpfreaks.com/topic/245716-mysql-foreach/#findComment-1262367 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/245716-mysql-foreach/#findComment-1262459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.