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 Link to comment https://forums.phpfreaks.com/topic/291945-php-multi-pages-function/ Share on other sites More sharing options...
trq Posted October 20, 2014 Share Posted October 20, 2014 Where exactly are you stuck? Link to comment https://forums.phpfreaks.com/topic/291945-php-multi-pages-function/#findComment-1494233 Share on other sites More sharing options...
abubaker0000 Posted October 20, 2014 Author Share Posted October 20, 2014 where excatly ? Link to comment https://forums.phpfreaks.com/topic/291945-php-multi-pages-function/#findComment-1494235 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?" Link to comment https://forums.phpfreaks.com/topic/291945-php-multi-pages-function/#findComment-1494257 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>'; } } } Link to comment https://forums.phpfreaks.com/topic/291945-php-multi-pages-function/#findComment-1494277 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. Link to comment https://forums.phpfreaks.com/topic/291945-php-multi-pages-function/#findComment-1494371 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.