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
Call Stack
#TimeMemoryFunctionLocation
10.0023412632{main}( ).../index.php:0
20.08374262504Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.08374262504Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.290111453432Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.290911477696Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.291711533024Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.292011560424require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.300011960056K2ControllerItem->execute( ).../k2.php:64
90.300011960056K2ControllerItem->display( ).../BaseController.php:710
100.310112610760K2ControllerItem->display( ).../item.php:78
110.310112610760K2ControllerItem->display( ).../controller.php:19
120.314712981800Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.315513002168K2ViewItem->display( ).../ViewController.php:102
140.383515926360K2ViewItem->display( ).../view.html.php:742
150.383515926360K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.385116099296include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
  • Rate this item
    (0 votes)
  • Published in PHP
  • Read 1585 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
Call Stack
#TimeMemoryFunctionLocation
10.0023412632{main}( ).../index.php:0
20.08374262504Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.08374262504Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.290111453432Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.290911477696Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.291711533024Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.292011560424require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.300011960056K2ControllerItem->execute( ).../k2.php:64
90.300011960056K2ControllerItem->display( ).../BaseController.php:710
100.310112610760K2ControllerItem->display( ).../item.php:78
110.310112610760K2ControllerItem->display( ).../controller.php:19
120.314712981800Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.315513002168K2ViewItem->display( ).../ViewController.php:102
140.383515926360K2ViewItem->display( ).../view.html.php:742
150.383515926360K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.385116099296include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
back to top