Jump to content

php multi pages function


abubaker0000

Recommended Posts

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>';
		}
	}
	
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.