Ver Mensaje Individual
  #13 (permalink)  
Antiguo 20/02/2010, 23:55
Pancho_Khan
 
Fecha de Ingreso: julio-2009
Ubicación: Montevideo, UY
Mensajes: 129
Antigüedad: 14 años, 9 meses
Puntos: 1
Respuesta: Consulta complicada

Acá mando los codigos:

Consulta que gagrega un nuevo usuario:
Código PHP:
$result mysql_query("INSERT INTO usuarios (nombre, apellido, nic, clave, tipo, foto)
VALUES ('$nombre', '$apellido', '$apellido', '$apellido', 3, '$nombre_foto')"
); 
Esto está verificado y lo guarda bien.

Consulta que gagrega una nueva columna:
Código PHP:
$result mysql_query("INSERT INTO columnas (id_columnista, fecha, titulo, resumen, columna)
VALUES ('$id', '$fecha_hoy', '$titulo', '$resumen', '$columna')"
); 
Esto está verificado y lo guarda bien. Los id son autonumericos.

Y con esta consulta estoy levantando la información en cuestión:
Código PHP:
$tabla mysql_query("SELECT t1.* FROM
(SELECT u.id, u.nombre, u.apellido, u.foto, c.id idd, c.id_columnista columnista, c.fecha, c.titulo, c.resumen, c.columna
FROM columnas c INNER JOIN usuarios u ON u.id = c.id_columnista
ORDER BY c.id,  c.fecha DESC) t1 GROUP BY t1.columnista;" 
);
if(
$tabla){
   while(
$reg mysql_fetch_array($tabla)) {
      echo
"<table style='table-layout:fixed'>
                  <tr>                                     <td width='387' align='left'>
                        <span class='texte7'><strong>"
.$reg[idd]."-".$reg['titulo']."</strong></span>                             </td>
                     <td align='right'><span class='texte7'>"
.$reg['fecha']."</span></td>
      </tr>
               </table>    
               <table width='100%' border='0' cellspacing='2' cellpadding='3' class='tabla' style='table-layout:fixed' >                          <col align='left' width='80px'/>
      <col align='left'  width='300px' />
      <tr>
         <td rowspan='2' valign='top'>
            <div style='float:left;'>
        <img src='admin/fotos_columnistas/"
.$reg['foto'].".jpg' hspace='5' width='75' height'75' clear:right;border:1px solid black'><br />
                   <span class='texte6' align='center'>&nbsp;&nbsp;"
.$reg['nombre']."<br />&nbsp;&nbsp;".$reg['apellido']."</span>
            </div>
         </td>
         <td valign='top'>    
            <span class='texto_para_detalle' align='right'>"
.$reg['resumen']." </span><br />                                     </td>
                  </tr>
                  <tr>
         <td align='right'valign='bottom'><a  class='usuario' href='noticia_detalle.php?id="
.$reg['id']."'> Leer nota </a></td>
      </tr>
               </table>"
;                    
            } 
// fin del while
         
}
      }
   }
?>