Pagination

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
freemojorisin
Forum Newbie
Posts: 7
Joined: Fri Mar 11, 2005 11:34 am

Pagination

Post by freemojorisin »

Hi I'm trying to do a pagination with this piece of code

Code: Select all

$length = 15;
if(isset($_GET["pag"]))
	$start = ($_GET["pag"] * $length) - $length;
else
{
   $start = 0;
   $pag = 1;
}

if($_GET["pag"] == 0)
{
   $start = 0;
   $pag = 1;
}
	
	$sql = "select count(*) as numero from noticias";
	$resultado = mysql_db_query($GLOBALS["nombre_db"],$sql,$conexion) or die ("<br>Error => " . $sql);	
	$temp = mysql_fetch_array($resultado);
	$numero = $temp[0];

	//echo "<br>$sql <br> el numero de noticias es $numero";
	$numero_paginas = ceil($numero/$length);
	//echo "<br> NUmero de paginas que resultan => " . $numero_paginas;
		
	$sql = "select * from noticias order by fecha DESC limit $start,$length";
	//echo "<br>" . $sql;
	$resultado = mysql_db_query($GLOBALS["nombre_db"],$sql,$conexion) or die ("<br>Error => " . $sql);
	if (mysql_num_rows($resultado) > 0) 
	  $hay = "si";
the problem is that I have to use a SQL Server 2000 database so when I'm going to limit the number it is wrong because SQL Server doesn't have the LIMIT clause like MySql.

How can I perform this task???

Thanks


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply