sql >> Database >  >> RDS >> Mysql

Resultaat van mysql-query van variabele afdrukken

Hiermee wordt de vraag afgedrukt:

$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`)";

$dave= mysql_query($query) or die(mysql_error());
print $query;

Hiermee worden de resultaten afgedrukt:

$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`)";

$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";
}


  1. PHP en MySQL optionele WHERE voorwaarden

  2. Toon (lijst) MySQL-databases op Linux via de opdrachtregel

  3. Voorbeeld Oracle-functie (retournummer)

  4. MySQL, REGEXP - Vind woorden die alleen de volgende exacte letters bevatten