note 81348 added to function.mysql-query

From: Date: Sat, 23 Feb 2008 19:06:29 +0000
Subject: note 81348 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-136443@lists.php.net to get a copy of this message
Here is a small neat function to print out the mysql result as a html table: <?php function echo_result($result) { ?><table><tr><? if(! $result) { ?><th>result not valid</th><? } else { $i = 0; while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result, $i); ?><th style="white-space:nowrap"><?=$meta->name?></th><? $i++; } ?></tr><? if(mysql_num_rows($result) == 0) { ?><tr><td colspan="<?=mysql_num_fields($result)?>"> <strong><center>no result</center></strong> </td></tr><? } else while($row=mysql_fetch_assoc($result)) { ?><tr style="white-space:nowrap"><? foreach($row as $key=>$value) { ?><td><?=$value?></td><? } ?></tr><? } } ?></table><? } ?> ---- Server IP: 217.13.201.10 Probable Submitter: 217.233.132.219 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- https://master.php.net/note/edit/81348 Del: integrated -- https://master.php.net/note/delete/81348/integrated Del: useless -- https://master.php.net/note/delete/81348/useless Del: bad code -- https://master.php.net/note/delete/81348/bad+code Del: spam -- https://master.php.net/note/delete/81348/spam Del: non-english -- https://master.php.net/note/delete/81348/non-english Del: in docs -- https://master.php.net/note/delete/81348/in+docs Del: other reasons-- https://master.php.net/note/delete/81348 Reject -- https://master.php.net/note/reject/81348 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136443) next »