Page 1 of 1

Pagination

Posted: Thu Mar 17, 2005 2:51 pm
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]

Posted: Thu Mar 17, 2005 3:09 pm
by feyd