Tema: Consulta SQL
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/04/2008, 15:08
Avatar de petoko
petoko
 
Fecha de Ingreso: noviembre-2007
Ubicación: talcahuano chile
Mensajes: 173
Antigüedad: 17 años, 3 meses
Puntos: 0
Re: Consulta SQL

espero que te sirva esto

Código PHP:
<?
 $sql_query
="select codigo_trib, nombre_trib, direccion_trib,fono_trib, fono2_trib, fono3_trib from tribunal order by codigo_trib";
  
$resultado mysql_query($sql_query);
 
  
$comprueba=mysql_affected_rows();
 
  if(
$comprueba 0)
  {
 
     
?>
  <table width="95%" align="center" border="2" bordercolor="#00FFCC">
<tr>
<th>Codigo Tribunal</th>
<th>Nombre Tribunal</th>
<th>Direccion</th>
<th>telefono 1</th>
<th>Telefono 2</th>
<th>Telefono 3</th>
</tr> 
<?php
 $num_fila 
0;  
  while (
$row mysql_fetch_array($resultado))
  {
 
  echo 
"<tr ";
    if (
$num_fila%2==0)
       echo 
"bgcolor=#dddddd"//si el resto de la división es 0 pongo un color
    
else
       echo 
"bgcolor=#ddddff"//si el resto de la división NO es 0 pongo otro color
    
echo ">"
    echo 
'<td>' .$row[codigo_trib].'</td>';
    echo 
'<td>' .$row[nombre_trib].'</td>';
    echo 
'<td>' .$row[direccion_trib].'</td>';
    echo 
'<td>' .$row[fono_trib].'</td>';
    echo 
'<td>' .$row[fono2_trib].'</td>';
    echo 
'<td>' .$row[fono3_trib].'</td></tr>';
 
 
$num_fila++;
 
  }
  }
ahy esta la consulta y comno se imprime en pantalla despues dentro de una tabla