Ver Mensaje Individual
  #21 (permalink)  
Antiguo 09/05/2007, 11:08
Avatar de Javiglez
Javiglez
 
Fecha de Ingreso: marzo-2006
Ubicación: Valladolid
Mensajes: 496
Antigüedad: 18 años, 2 meses
Puntos: 0
Re: Mostrar datos de base de datos

Asi da gusto Raulmmmm, gracias por tu paciencia para ayudarme a ver si damos rápido con ello,cuenta y cuenta2 son dos pantallas iguales solo que mostrando diferentes registros de una base de datos por eso no entiendo que muestre bien una o la otra mal, creo que las consultas estan bien que tiene que ser una tontería que me dejo. vamos a ver recapitulo.

cuenta.php
Código PHP:
<?php 
        
include("conectarse_bd.php"); 
        include(
"login.php"); 
        
$result mysql_query("SELECT * FROM Clientes WHERE login='".$_SESSION["usNick"]."' AND pass='".$_SESSION["usPass"]."'");   
        if(
$loginCorrecto)  
        {  
            
$mostrar "Bienvenido !!!!";
            }  
            else  
            {    
            
$mostrar 'Bienvenido visitante, el sistema no te ha reconocido, sino te autentificas no podras realizar ninguna de las funciones';
            
//falla
            
header("Location: acceso.html");  
        } 
        if (
$row mysql_fetch_array($result)){      
?>

//------------------------

    <?php 
        
echo "<p style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold; float:right;'  > Usuario   ".$_SESSION['usNick']." ";
    
?>
     <form id="form1" method="post" action="">
        <fieldset class="clase1"><legend>Datos Personales</legend>
        <label for="nombre">Nombre</label><input  name="nombre" type="text" id="nombre" value= "<?php echo $row["nombre"];?>" size="40" readonly="readonly"/>
        <br />
        <label for="apellidom">Apellido </label><input name="apellido1" type="text" id="apellido1" value= "<?php echo $row["apellido1"];?>" size="40" readonly="readonly"/>
        <br />
        <label for="apellidop">Apellido </label><input name="apellido2" type="text" id="apellido2" value= "<?php echo $row["apellido2"];?>" size="40" readonly="readonly" />
        <br />
        <label for="Email">Email</label> 
        <input name="mail" type="text" id="mail" value= "<?php echo $row["mail"];?>" size="40" readonly="readonly"/>
        <br />    
        <label for="telefono">Telefono</label><input name="telefono" type="text" id="telefono" value= "<?php echo $row["telefono"];?>" size="40" readonly="readonly" />
        <br />    
        <label for="direccion">Dirección</label><input name="direccion" type="text" id="direccion" value= "<?php echo $row["direccion"];?>" size="40" readonly="readonly" />
        <br />
    
    
    </fieldset>

    <fieldset class="clase1"><legend>Trabajos en curso</legend>

    <?php
    
        $re
$row["dni"];
            
$sql="SELECT * FROM Expedientes WHERE dni='$re'";
            
$result mysql_query($sql);
            if(isset(
$result) && mysql_num_rows($result)>0)
            {
                 while(
$fila=mysql_fetch_assoc($result))
                 {
                      
// echo $fila['nombre']."<br>";
                       
echo "<a href=\"../cuenta2.php\">".$fila['nombre']. "<br>""</a>";  
                       echo 
"<br>";
                 }
            }
    
?> 
    </fieldset>
    </form>
    <?
        
//si hay resultados crea tabla
        
if ($row mysql_fetch_array($result)){ 
        echo 
"<table border = '1'> \n";                                     
        
//Mostramos los nombres de las tablas 
        
mysql_field_seek($result,0); 
        echo 
"<tr> \n";
        echo  
"<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Fecha</b></td> \n";
        echo  
"<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Nombre</b></td> \n";
        echo  
"<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Ver</b></td> \n";
        
          
        echo  
"<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Eliminar</b></td> \n";
        
        echo  
"<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Modificar</b></td> \n";
        echo 
" </tr> \n"
        echo 
"</tr> \n"
        
        do { 
        echo 
"<tr> \n"//para ver el cliente entero
    
?><form name="form1" method="post" action="datos_expedientes.php">
    <?
    
echo "<td>"?>
  <textarea cols="22" rows="1" name="fecha" readonly style="overflow:auto; border-width: 2px; font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000;  text-align:center;"><?php echo $row["fecha"];?></textarea>
  </TD>

    <? "</td> \n"

    echo 
"<td>"?>
      <textarea cols="70" rows="1" name="nombre" readonly style="overflow:auto; border-width: 2px; font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000;  text-align:center;"><?php echo $row["nombre"];?></textarea>
    <? "</td> \n"
    
?>

    <?
    
echo "<td>"?>
    <input type="submit" name="Submit" value="Ver detalles" style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000;  text-align:center;"></TD>
    </form>
    <? echo "<td>"?>
    <form name="form" method="post" action="confirmacion_baja_exp.php">
     <input name="expediente" type="hidden" value="<? echo $row["expediente"]; ?>">
     <input type="submit" name="Submit2" value="Eliminar" style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000;  text-align:center;"></TD>
    </form>                         
    <? echo "<td>"?>
        <form name="form" method="post" action="modificar_expediente.php">
         <input name="expediente" type="hidden" value="<? echo $row["expediente"]; ?>">
         <input type="submit" name="Submit2" value="Modificar" style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000;  text-align:center;"></TD>
        </form> 
    <?     
     
"</td> \n"?>
    <?
        
echo "</tr> \n"
        
        } while (
$row mysql_fetch_array($result)); 
        } 
        }
//if
    
?>
y cuenta2.php

Código PHP:
<?php 
        
include("conectarse_bd.php"); 
        include(
"login.php");
        
$dnicliente $row["dni"];
        
$sql="SELECT * FROM Expedientes WHERE dni='$dnicliente' AND Expedientes.expediente='%s'";
        
$result mysql_query(sprintf$sqlmysql_real_escape_string$_GET['expediente'] ) ) );
        if(
$loginCorrecto)  
            {  
        
            }  
        else  
            {  
                
$mostrar 'Bienvenido visitante, el sistema no te ha reconocido, sino te autentificas no podras realizar ninguna de las funciones';
                
header("Location: acceso.html");  
            }  
            
?>
//----------------------------------------------------

<?php
        
echo "<p style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold; float:right;'  > Usuario   ".$_SESSION['usNick']." ";

do{
//seleccionar los expedientes con dni del usuario y expediente especifico que tendre que sacar mediante un formulario 
$link "Expediente nº %s %s<br>";
if(isset(
$result) && mysql_num_rows($result)>0)
{
    while(
$fila=mysql_fetch_assoc($result))
    {
        echo 
sprintf$link$fila['expediente'], $fila['nombre'] );
        echo 
"<br>";
    }
}
?>
</p>
  <fieldset class="clase1">
  <legend>FOTOS </legend>
      <?php
    $sql
="SELECT Expedientes.expediente, Documentos.nombre FROM Expedientes, Documentos WHERE Expedientes.dni='$dnicliente' AND Documentos.tipo='foto' AND Documentos.expediente=Expedientes.expediente AND Expedientes.expediente='%s'" ;
    
$result mysql_query(sprintf$sqlmysql_real_escape_string$_GET['expediente'] ) ) );
    
$nregistros=mysql_num_rows($result);
    if (
$nregistros!=0){
    While (
$registro=mysql_fetch_row($result))
                        {
                        echo 
'<a href="./UPLOAD/'.$registro[1].'" target="_blank">'.$registro[1]. '</a>';
                        echo 
"<br>";
                        }
                        }else{
                        echo 
"<p style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #FF0000; font-weight: bold;' > No hay archivos con este formato </p>";
                        }
    
?> 
       
    </fieldset>


    <fieldset class="clase1"><legend>TEXTOS </legend>

    <?php
        $sql
="SELECT Expedientes.expediente, Documentos.nombre FROM Expedientes, Documentos WHERE Expedientes.dni='$dnicliente' AND Documentos.tipo='texto' AND Documentos.expediente=Expedientes.expediente AND Expedientes.expediente='%s'" ;
        
$result mysql_query(sprintf$sqlmysql_real_escape_string$_GET['expediente'] ) ) );
        
$nregistros=mysql_num_rows($result);
        if (
$nregistros!=0){
        While (
$registro=mysql_fetch_row($result)){
        echo 
'<a href="./UPLOAD/'.$registro[1].'" target="_blank">'.$registro[1]. '</a>';
        echo 
"<br>";
        }
        }else{
        echo 
"<p style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #FF0000; font-weight: bold;' > No hay archivos con este formato </p>";
        }
    
?> 
    </fieldset>
<span class="Estilo12"></span>
    <fieldset class="clase1"><legend>PLANOS</legend>

        <?php
            $sql
="SELECT Expedientes.expediente, Documentos.nombre FROM Expedientes, Documentos WHERE Expedientes.dni='$dnicliente' AND Documentos.tipo='plano' AND Documentos.expediente=Expedientes.expediente AND Expedientes.expediente='%s'" ;
            
$result mysql_query(sprintf$sqlmysql_real_escape_string$_GET['expediente'] ) ) );
            
$nregistros=mysql_num_rows($result);
            if (
$nregistros!=0){
                While (
$registro=mysql_fetch_row($result)){
                    echo 
'<a href="./UPLOAD/'.$registro[1].'" target="_blank">'.$registro[1]. '</a>';
                    echo 
"<br>";
                    }
                    }else{
                            echo 
"<p style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #FF0000; font-weight: bold;' > No hay archivos con este formato </p>";
                         }
        } while (
$row mysql_fetch_array($result)); 
        
?>      
    </fieldset>
Si necesitas algun php más me lo dices aunque creo que no hace falta y la estructura de la base de datos esta en el primer POST.