
04/06/2007, 11:20
|
| | Fecha de Ingreso: mayo-2007
Mensajes: 48
Antigüedad: 17 años, 9 meses Puntos: 0 | |
Listar todos los registros codigo Pues el caso es que no me lista todos los registros que hay solo me registra el primero y no se xk aqui os pego mi codigo y a ver si me sabeis decir porque, yo por mas que lo intente no lo he conseguido, muchas gracias de antemano, por cierto este codigo es una plantilla que llama un htm y remplaza cosas como vereis:
Código:
<?php
session_start();
$file = fopen("tabla.htm", "r");
$html = fread($file, filesize("tabla.htm"));
fclose($file);
include('init.inc');
//Conectamos con la base de datos
$conect=mysql_connect($hostname_localhost, $username_localhost, $password_localhost);
$db=mysql_select_db($database_localhost, $conect);
$resguardos="SELECT * FROM resguardos";
$res=mysql_query($resguardos);
while ($row=mysql_fetch_array($res))
{
$cliente=$row['id_cliente'];
$clientes="SELECT * FROM clientes where id_cliente=$cliente";
$res2=mysql_query($clientes);
while ($row2=mysql_fetch_array($res2))
{
$nombre=$row2['nombre_apellidos'];
$num=$row['id_resguardo'];
$fechaentrada=$row['fecha_entrada'];
$estado=$row['estado_averia'];
$fac=$row['n_factura'];
$tabla="<tr><td>".$num."</td><td>".$fac."</td><td>".$cliente."</td><td>$nombre</td><td>".$fechaentrada."</td><td>".$estado."</td><td><a href='modificar_resguardo_plantilla.php?id_resguardo=xxnumxx&id_cliente=$cliente'><img src='imagenes/edit.png' alt='Modificar' width='16' height='16' border='0' /></a><a href='desactivar_averia.php?id_resguardo=xxnumxx'><img src='imagenes/desactiva.jpg' alt='Entregada' width='20' height='20' border='0' /></a><a href='ver_resguardo_pdf.php?id_resguardo=xxnumxx' target='_blank'><img src='imagenes/pdf.png' alt='Generar PDF' width='16' height='16' border='0' /></a><a href='borrar_resguardo.php?id_resguardo=xxnumxx'><img src='imagenes/delete.png' alt='Borrar' width='16' height='16' border='0' /onclick='if(confirm('¿Desea Borrar Realmente este Registro') == false){return false;}'/></a></td></tr>";
}
$html = str_replace("xxnumxx", $num, $html);
$html = str_replace("xxclientexx", $cliente, $html);
$html = str_replace("xxfechaentradaxx", $fechaentrada, $html);
$html = str_replace("xxfacxx", $fac, $html);
$html = str_replace("xxnombrexx", $nombre, $html);
$html = str_replace("xxestadoxx", $estado, $html);
$html = str_replace("xxtablaxx", $tabla, $html);
}
echo $html;
?>
|