I have this code which shows the total sale up till the current date , but it shows in this way
Array (
[Date] => 2014-01-25
[TotalSales] => 7
)
Is there any way , where i can show in this way Total Sale:7 And Date:2014-01-25 ?
<?php
$host = 'localhost';
$user = 'root';
$passwd = '';
$database = 'p_database';
$connect = mysql_connect($host,$user,$passwd) or die("could not connect to database");
$query = "SELECT DATE(order_time) AS Date, SUM(Quantity) AS TotalSales
FROM ss_orders,ss_ordered_carts
WHERE DATE(order_time) = DATE(NOW())
group by date;";
mysql_select_db($database,$connect);
$result = mysql_fetch_assoc(mysql_query($query));
print_r($result);
?>
You are using print_r
which Prints human-readable information about a variable . You can access the value by name
echo "TotalSale: ".$result['TotalSales'];
echo "Date: ".$result['Date'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With