jtracey0380 Posted March 11, 2010 Share Posted March 11, 2010 below is the basic code I am using - it counts the items that were fetched from the db - it lists the 5 items. HOW DO I GET THE REMAINDER OF ITEMS TO SHOW UP 5 AT A TIME? Thank you so much. <?php $db = mysql_connect('mysql_server', 'username', 'password'); if (!$db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } mysql_select_db('db_name'); $query = "SELECT `page_info` FROM `pages` ORDER BY `page_name` ASC LIMIT 5 , 5"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo '<p>Number of items found: '.$num_results.'</p>'; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo stripslashes($row['page_info']); echo '<br />'; } ?> Link to comment https://forums.phpfreaks.com/topic/194839-need-code-to-get-the-remainder-of-items-five-at-a-time/ Share on other sites More sharing options...
jtracey0380 Posted March 11, 2010 Author Share Posted March 11, 2010 on the limit it should be 0, 5 not 5, 0 sorry Link to comment https://forums.phpfreaks.com/topic/194839-need-code-to-get-the-remainder-of-items-five-at-a-time/#findComment-1024488 Share on other sites More sharing options...
jtracey0380 Posted March 11, 2010 Author Share Posted March 11, 2010 below is the basic code I am using - it counts the items that were fetched from the db - it lists the 5 items. HOW DO I GET THE REMAINDER OF ITEMS TO SHOW UP 5 AT A TIME? Thank you so much. <?php $db = mysql_connect('mysql_server', 'username', 'password'); if (!$db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } mysql_select_db('db_name'); $query = "SELECT `page_info` FROM `pages` ORDER BY `page_name` ASC LIMIT 5 , 5"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo '<p>Number of items found: '.$num_results.'</p>'; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo stripslashes($row['page_info']); echo '<br />'; } ?> Link to comment https://forums.phpfreaks.com/topic/194839-need-code-to-get-the-remainder-of-items-five-at-a-time/#findComment-1024514 Share on other sites More sharing options...
jtracey0380 Posted March 11, 2010 Author Share Posted March 11, 2010 in other words - let's say the script returns 500 results. i want to show them 5 at a time. I'm not sure how to do that. any help would be great. thanks. Link to comment https://forums.phpfreaks.com/topic/194839-need-code-to-get-the-remainder-of-items-five-at-a-time/#findComment-1024516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.