php – 从变量打印mysql查询结果

前端之家收集整理的这篇文章主要介绍了php – 从变量打印mysql查询结果前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我早些时候写了(在 PHP中),但是每次我尝试echo $test“,我只是得到资源id 5.有没有人知道如何从变量中实际打印出mySQL查询
$dave= MysqL_query("SELECT order_date,no_of_items,shipping_charge,SUM(total_order_amount) as test FROM `orders` WHERE DATE(`order_date`) = DATE(NOW()) GROUP BY DATE(`order_date`)") or die(MysqL_error());
print $dave;
这将打印出查询
$query = "SELECT order_date,SUM(total_order_amount) as test FROM `orders` WHERE DATE(`order_date`) = DATE(NOW()) GROUP BY DATE(`order_date`)";

$dave= MysqL_query($query) or die(MysqL_error());
print $query;

这将打印出结果:

$query = "SELECT order_date,SUM(total_order_amount) as test FROM `orders` WHERE DATE(`order_date`) = DATE(NOW()) GROUP BY DATE(`order_date`)";

$dave= MysqL_query($query) or die(MysqL_error());

while($row = MysqL_fetch_assoc($dave)){
    foreach($row as $cname => $cvalue){
        print "$cname: $cvalue\t";
    }
    print "\r\n";
}

猜你在找的PHP相关文章