![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
04/02/2002, 10:30
|
| | Fecha de Ingreso: enero-2002
Mensajes: 110
Antigüedad: 23 años Puntos: 0 | |
Re: Paginar resultado de consulta sql con php Gracias de todos modos CHUBU, aunque ya me funciona y es de otra manera:
<pre>
<?php
$db=mysql_connect("localhost","root ","");
mysql_select_db("empresa",$db);
IF ($num>0) { $n=$num;} ELSE { $n=0; }
$conta="SELECT id FROM personal ";
$result2=mysql_query($conta,$db);
$quants=mysql_num_rows($result2);
$sql="SELECT * FROM personal ORDER BY fecha ASC LIMIT ".$n.", 5 ";
$result=mysql_query($sql,$db);
if ($myrow=mysql_fetch_array($result)){
echo "<font size=4 color=red face=arial><b>VISITAS DE LABORATORIOS:</b></font><br><br>\n";
echo "<table border=0 cellpadding=3 cellspacing=0 width=80%>\n";
echo "<tr><td bgcolor='#657085' width='10%' class='estilo1'><center><script language='JavaScript'>
<!--
var today = new Date();
date = today.getDate();
month = today.getMonth();
year = today.getYear();
day = today.getDay();
function makeArray() {
for (i = 0; i<makeArray.arguments.length; i++)
this[I] = makeArray.arguments;
}
var monthname = new makeArray('ENERO','FEBRERO','MARZO','ABRIL','MAYO' ,'JUNIO','JULIO','AGOSTO','SEPTIEMBRE','OCTUBRE',' NOVIEMBRE','DICIEMBRE');
var thismonth = monthname[month];
document.write(thismonth);
//-->
</script></center></td><td width='80%' bgcolor='#657085'></td></tr></table><br>\n";
echo "<table border=0 cellpadding=3 cellspacing=0 width=80%>\n";
echo "<tr><td bgcolor='#659999' width='5%'><center><font color='white'><b>ID</b></font></center></td><td bgcolor='#657085' width='10%'><center><font color='white'><b>DÍA</b></font></center></td><td bgcolor='#BCC1CD' width='20%'><b>VISITA 1</b></td><td width='20%' bgcolor='#FFF7D7'><b>VISITA 2</b></td><td bgcolor='#BCC1CD' width='20%'><b>VISITA 3</b></td><td width='20%' bgcolor='#FFF7D7'><b>VISITA 4</b></td></tr></table><br>\n";
echo "<table border=0 cellpadding=3 cellspacing=0 width=80%>\n";
do
{
echo "<tr><td bgcolor='#659999' width='5%'><center><font color='white'><b>".$myrow["id"]."</b></font></center></td><td bgcolor='#657085' width='5%'><center><font color='white'><b>".$myrow["fecha"]."</b></font></center></td><td bgcolor='#BCC1CD' width='20%'>".$myrow["nombre_1"]."
</td><td width='20%' bgcolor='#FFF7D7'>".$myrow["nombre_2"]."</td><td bgcolor='#BCC1CD' width='20%'>".$myrow["nombre_3"]."</td><td width='20%' bgcolor='#FFF7D7'>".$myrow["nombre_4"]."</td></tr>\n";
echo "<tr><td bgcolor='#659999'></td><td bgcolor='#657085' width='10%' width='20%'></td><td bgcolor='#BCC1CD' width='20%'>".$myrow["laboratorio"]."</td><td width='20%' bgcolor='#FFF7D7'>".$myrow["laboratorio_2"]."</td><td bgcolor='#BCC1CD' width='20%'>".$myrow["laboratorio_3"]."</td><td width='20%' bgcolor='#FFF7D7'>".$myrow["laboratorio_4"]."</td></tr>\n";
echo "<tr><td bgcolor='white'colspan=5 width='100%'></td></tr>\n";
}
while($myrow=mysql_fetch_array($result));
echo "</table>\n";
}
echo "<table border='0' width='80%'><tr><td colspan='2'><hr noshade></td></tr>\n";
echo "<tr><td align='left'> Encontrados ".$quants." resultados </td>\n";
echo "<td align='right'>\n";
echo "<font face='Arial' size='-1' color='#336699'>Páginas: </font>\n";
for ($i=0; $i< $quants; $i=$i+5)
{
$a=$a+1;
IF ($n==$i)
{
echo "<A HREF='datos.php?num=".$i."'>[".$a."]</A>\n";
}
ELSE
{
echo "<A HREF='datos.php?num=".$i."'>[".$a."]</A>\n";
}
}
echo "</td></tr></table>\n";
mysql_close ($db);
?> </pre> |