abubaker0000 Posted October 20, 2014 Share Posted October 20, 2014 hi how can I make a function for multi pages , the function accept two arguments (page name, number of records which showed in one page). and returns the data from the table , also returns the number of pages Quote Link to comment Share on other sites More sharing options...
trq Posted October 20, 2014 Share Posted October 20, 2014 Where exactly are you stuck? Quote Link to comment Share on other sites More sharing options...
abubaker0000 Posted October 20, 2014 Author Share Posted October 20, 2014 where excatly ? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 20, 2014 Share Posted October 20, 2014 What trq means is "what code are you using now?" Quote Link to comment Share on other sites More sharing options...
abubaker0000 Posted October 20, 2014 Author Share Posted October 20, 2014 I make this function but not work function work_image_multipages($num_of_itmes,$sended_page) { global $con; if(!isset($_GET['page'])) { $page=1; } else { $page=(int)$_GET['page']; } $records_at_page=$num_of_itmes; $q=mysqli_query($con,'select * from images'); $records_count=mysqli_num_rows($q); mysqli_free_result($q); $page_count=(int)ceil($records_count/$records_at_page); if(($page>$page_count)||($page<=0)) { mysqli_close($con); die('no pages'); } $start=($page-1)*$records_at_page; $end=$records_at_page; if($records_count!=0) { $query=mysqli_query($con,'select * from images LIMIT $start,$end'); $icount=mysqli_num_rows($query); $items=array(); for($i=0; $i<$icount; $i++) { $items[count($items)]=mysqli_fetch_object($query); } } mysqli_free_result($query); return($items); //print the numbers of pages for($i=0; $i<=$page_count; $i++) { if($page==$i) { echo $page; } else { echo '<a href="$sended_page?page'.$i.'">'.$i.'</a>'; } } } Quote Link to comment Share on other sites More sharing options...
trq Posted October 22, 2014 Share Posted October 22, 2014 I make this function but not work Helpful. 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.