php 表格 foreach 显示 select 结果

<?php
$con = mysql_connect("localhost","tdg","tdg");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("tdg", $con);

$result = mysql_query("SELECT * FROM  `client`");
?>

<table border="2">
    <?php while ($row = mysql_fetch_assoc($result)): ?>
    <tr>
        <?php foreach($row as $key=>$value) {   
            echo "<td>$key: $value</td>\n "; 
        } ?> 
    </tr>          
    <?php endwhile; ?>
</table>
<?php
mysql_close($con);
?>
Last modified onMonday, 29 April 2013 13:18

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
  • Rate this item
    (0 votes)
  • Published in PHP
  • Read 1495 times
More in this category: php sql 不为空 »

Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
back to top