所以我早些时候写了(在
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"; }