Advertisement
slovacus

Get HTML Table width php

Jul 28th, 2011
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. function getHtmlTable($result){
  2.     // receive a record set and print
  3.     // it into an html table
  4.     $out = '<table>';
  5.     for($i = 0; $i < mysql_num_fields($result); $i++){
  6.         $aux = mysql_field_name($result, $i);
  7.         $out .= "<th>".$aux."</th>";
  8.     }
  9.     while ($linea = mysql_fetch_array($result, MYSQL_ASSOC)) {
  10.         $out .= "<tr>";
  11.         foreach ($linea as $valor_col) $out .= '<td>'.$valor_col.'</td>';
  12.         $out .= "</tr>";
  13.     }
  14.     $out .= "</table>";
  15.     return $out;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement