Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/04/2010, 07:35
warbandit69
 
Fecha de Ingreso: diciembre-2008
Ubicación: http://www.solucionesrios.tk/
Mensajes: 413
Antigüedad: 15 años, 4 meses
Puntos: 19
Respuesta: Paginación con SQL Server en PHP

Ya que nadie me pudo ayudar, solucione el problema usando un arreglo a continuación les pego el codigo a la gente para que los ayuden

Código:
<?php $sql = "SELECT     RVMservicio.servicio AS TIPO, RVMservicio.correlativo AS 'No. PROYECTO', RVMservicio.nombrebarco AS BARCO, RVMagente.compania AS AGENTE, 
                      RVMservicio.fecha_llegada AS ETA, RVMservicio.fecha_salida AS ETD, RVMpuertos.puerto AS PUERTO, RVMservicio.estatus, 
                      RVMservicio.tecnico AS IDTEC
FROM         RVMservicio INNER JOIN
                      RVMagente ON RVMservicio.compania_agente = RVMagente.id_agente INNER JOIN
                      RVMpuertos ON RVMservicio.puerto = RVMpuertos.id_puerto
WHERE     (RVMservicio.estatus <> 'Canceled') AND (RVMservicio.estatus <> 'Finished') ".$sql2."
ORDER BY RVMservicio.correlativo DESC";
$servicios = $db->Execute($sql);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RVM</title>
</head>

<body>
<p>
  <?php
$i = 0;
$arreglo = array();
$tablas = array();
if (!$servicios) {
	print $db->ErrorMsg();
} else {
	while (!$servicios->EOF) {
		$i++;
		$enlace1 = "<center>
    <a href='imprimir.php?recordID=".$servicios->fields[1]."' style='text-decoration:none; border:none;' target='_blank'><img src='images/print.png' width='30' height='30' style='text-decoration:none; border:none;' alt='Print'/></a>
  </center>";

		if ($servicios->fields[7]=="Canceled") { $estatus = "Cancelado"; }
		if ($servicios->fields[7]=="Finished") { $estatus = "Finalizado"; }
		if ($servicios->fields[7]=="Unasigned") { $estatus = "Oficina Preasignada"; }
		if ($servicios->fields[7]=="PreFactured") { $estatus = "Por Facturar"; }
		if ($servicios->fields[8]==0) { if ($servicios->fields[7]=="Asigned") { $estatus = "Oficina Asignada"; } }
		if ($servicios->fields[8]!=0) { if ($servicios->fields[7]=="Asigned") { $estatus = "T&eacute;cnico Preasignado"; } }
		if ($servicios->fields[7]=="Technichian Asigned") { $estatus = "T&eacute;cnico Asignado"; }
		if ($servicios->fields[7]=="Technician Asigned") { $estatus = "T&eacute;cnico Asignado"; }
		if ($servicios->fields[7]=="Waiting for parts") { $estatus = "Por Partes"; }
		if ($servicios->fields[7]=="By Monitoring") { $estatus = "Por Seguimiento"; }
		$arreglo[$i] = array('ENLACE 1' => $enlace1,'TIPO' => $servicios->fields[0], 'No. PROYECTO' => $servicios->fields[1], 'BARCO' => $servicios->fields[2], 'AGENTE' => $servicios->fields[3], 'ETA' => $servicios->fields[4], 'ETD' => $servicios->fields[5], 'PUERTO' => $servicios->fields[6], 'ESTADO' => $estatus, 'TEC' => $servicios->fields[8]);
		$servicios->MoveNext();
	}
	
}
$perpage = 10; //Obviously you would want to change this to something higher, depending on the content.
if(isset($_GET['start'])) $start = $_GET['start']; else $start = 0;
$numposts = count($arreglo);
$data = array_slice($arreglo, $start, $perpage);
?>
</p>
<p>&nbsp;</p>
<table border="0" align="center">
  <tr bgcolor="#000000" class="asd">
	<td align="center"><strong>&nbsp;</strong></td>
    <td align="center"><strong>TIPO</strong></td>
    <td align="center"><strong>No. PROYECTO</strong></td>
    <td align="center"><strong>BARCO</strong></td>
    <td align="center"><strong>AGENTE</strong></td>
    <td align="center"><strong>ETA</strong></td>
    <td align="center"><strong>ETD</strong></td>
    <td align="center"><strong>PUERTO</strong></td>
    <td align="center"><strong>ESTADO</strong></td>
    <td align="center"><strong>&nbsp;</strong></td>
    <td align="center"><strong>&nbsp;</strong></td>
    <td align="center"><strong>&nbsp;</strong></td>
    <td align="center"><strong>&nbsp;</strong></td>
  </tr><?php
foreach($data as $k => $v)
{ ?>
<?php 
	$fechadesalida = $data[$k]['ETD'];
	// Comparo las fechas en formato UNIX y especifico el color de la tabla.
	$fecha_actual=mktime(0,0,0,date('m'),date('d'),date('Y'));
	$fecha_operar=$fechadesalida;
	list($dia,$mes,$año)=explode("/",$fecha_operar);
	$fecha_operar=mktime(0,0,0,$mes,$dia,$año);
	if ($fecha_actual > $fecha_operar){
		echo "<tr class='Rojo'>";
	}
	if ($fecha_actual < $fecha_operar){
		echo "<tr class='Verde'>";
	}
	if ($fecha_actual == $fecha_operar){
		echo "<tr class='Amarillo'>";
	}
	if ($data[$k]['ESTADO'] == 'Por Facturar'){
		echo "<tr class='PreFacturar'>";
	}
?>
    <td><?php echo $data[$k]['ENLACE 1']; ?></td>
    <td><?php echo $data[$k]['TIPO']; ?></td>
    <td><?php echo $data[$k]['No. PROYECTO']; ?></td>
    <td><?php echo $data[$k]['BARCO']; ?></td>
    <td><?php echo $data[$k]['AGENTE']; ?></td>
    <td><?php echo $data[$k]['ETA']; ?></td>
    <td><?php echo $data[$k]['ETD'];?></td>
    <td><?php echo $data[$k]['PUERTO']; ?></td>
    <td><?php echo $data[$k]['ESTADO']; ?></td>
    <?php if ($data[$k]['ESTADO'] == 'Por Facturar') { ?>
	<td width="30">&nbsp;</td>
    <td width="30">&nbsp;</td>
    <td width="30">&nbsp;</td>
    <td width="30">&nbsp;</td>
	<?php } ?>
    <?php 
	if(empty($_SESSION['oficina'])){
	if (empty($_SESSION['tecnico'])) { 
	if ($data[$k]['ESTADO'] == 'Oficina Preasignada') {
	?>
	<td width="30"><?php  if($nivel==1) {?><center>
      <span class="textoscuadros"><a href='asignado.php?recordID=<?php echo $data[$k]['No. PROYECTO']."_Asigned"; ?>'><img src="images/Imagen_Asignar.png" width="30" height="30" style="border:none"/></a> </span>
    </center><?php } ?></td>
    <td width="30"><center>
      <span class="textoscuadros"><a href='reasignar_servicio.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_ReAsignar.png" width="30" height="30" style="border:none"/></a> </span>
    </center></td>
    <td width="30"><center>
      <span class="textoscuadros"><a href='modificar_todo.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_Modificar.png" width="30" height="30" style="border:none"/></a> </span>
    </center></td>
    <td width="30"><?php if ($nivel==1) {?><center>
      <span class="textoscuadros"><a href='cancelaciones.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_Cancelar.png" width="30" height="30" style="border:none"/></a> </span>
    </center><?php } else { echo ""; } ?></td>
<?php  	} 
		}
		}
?>
    <?php if ($data[$k]['ESTADO'] == 'Oficina Asignada' or $data[$k]['ESTADO'] == 'T&eacute;cnico Preasignado') { ?>
	<td width="30"><?php if($data[$k]['ESTADO'] == 'T&eacute;cnico Preasignado') { ?>
	<?php  if ($data[$k]['TEC']!=0) { if($nivel!=1) { ?>
    <a href="asignarhojatrabajo2.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>_tec"><img src="images/Imagen_Asignar.png" width="30" height="30" style="border:none"/></a>
    <?php }  }?>
	<?php } ?></td>
    <td width="30"><center>
      <span class="textoscuadros"><a href='reasignar_servicio.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_ReAsignar.png" width="30" height="30" style="border:none"/></a> </span>
    </center></td>
    <td width="30"><center>
      <span class="textoscuadros"><a href='modificar_todo.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_Modificar.png" width="30" height="30" style="border:none"/></a> </span>
    </center></td>
    <td width="30"><?php if ($nivel==1) {?><center>
      <span class="textoscuadros"><a href='cancelaciones.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_Cancelar.png" width="30" height="30" style="border:none"/></a> </span>
    </center><?php } else { echo ""; } ?></td>
	<?php } ?>
    <?php if ($data[$k]['ESTADO'] == 'T&eacute;cnico Asignado') { ?>
	<td width="30">&nbsp;</td>
    <td width="30"><center>
      <span class="textoscuadros"><a href='reasignar_servicio.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_ReAsignar.png" width="30" height="30" style="border:none"/></a> </span>
    </center></td>
    <td width="30"><center>
      <span class="textoscuadros"><a href='modificar_todo.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_Modificar.png" width="30" height="30" style="border:none"/></a> </span>
    </center></td>
    <td width="30"><?php if ($nivel==1) {?><center>
      <span class="textoscuadros"><a href='cancelaciones.php?recordID=<?php echo $data[$k]['No. PROYECTO']; ?>'><img src="images/Imagen_Cancelar.png" width="30" height="30" style="border:none"/></a> </span>
    </center><?php } else { echo ""; } ?></td>
	<?php } ?>
  </tr>
    
<?php }?>
</table>
<?php

$text = "";
if($start > 0)
{
	$text .= '<a href="cartelera5.php?start='.($start - $perpage).'"><img src="images/MENOS.png" style="height:30px; width:30px; border:none;" /></a>';
}
if($start > 0 && $numposts > $perpage && $start < $numposts - $perpage)
{
	$text .= ' | ';
}
if($numposts > $perpage && $start < $numposts - $perpage)
{
	$text .= '<a href="cartelera5.php?start='.($start + $perpage).'"><img src="images/MAS.png" style="height:30px; width:30px; border:none;" /></a>';
}
echo $text;
?>
</body>
</html>