Posted By

ginoplusio on 02/01/10


Tagged

mysql table html set mysqli record


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

liamchapman
ginoplusio


MySQLi convert a result set to an HTML table


 / Published in: PHP
 

URL: http://www.barattalo.it/2010/01/29/10-php-usefull-functions-for-mysqli-improved-stuff/

  1. function getHtmlTable($rs){
  2. // receive a record set and print
  3. // it into an html table
  4. $out = '<table>';
  5. while ($field = $rs->fetch_field()) $out .= "<th>".$field->name."</th>";
  6. while ($linea = $rs->fetch_assoc()) {
  7. $out .= "<tr>";
  8. foreach ($linea as $valor_col) $out .= '<td>'.$valor_col.'</td>';
  9. $out .= "</tr>";
  10. }
  11. $out .= "</table>";
  12. return $out;
  13. }

Report this snippet  

You need to login to post a comment.