Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/01/2008, 21:30
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
Re: construyendo celdas con php

<?php
Include "base.inc" // aca te conectas a tu base de datos

function array2table($arr,$width) // de PHP.net
{
$count = count($arr);
if($count > 0){
reset($arr);
$num = count(current($arr));
echo "<table align=\"center\" border=\"1\"cellpadding=\"5\" cellspacing=\"0\" width=\"$width\">\n";
echo "<tr>\n";
foreach(current($arr) as $key => $value){
echo "<th>";
echo $key."&nbsp;";
echo "</th>\n";
}
echo "</tr>\n";
while ($curr_row = current($arr)) {
echo "<tr>\n";
$col = 1;
while (false !== ($curr_field = current($curr_row))) {
echo "<td>";
echo $curr_field."&nbsp;";
echo "</td>\n";
next($curr_row);
$col++;
}
while($col <= $num){
echo "<td>&nbsp;</td>\n";
$col++;
}
echo "</tr>\n";
next($arr);
}
echo "</table>\n";
}
}
$query = "SELECT * FROM $tabla";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){ // mysql_fetch_array($result,MYSQL_ASSOC)
$array[] = $row;
}


$query = "select DISTINCT nombre,apellido,edad from documentos WHERE nombre='andres' AND edad!='";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){ // mysql_fetch_array($result,MYSQL_ASSOC)
$array[] = $row;
}

array2table($array,600); // Will output a table of 600px width

?>
__________________
Salu2!