how can i get the sum total of a column, in a table from one mysql database?Well my code is
Code: Select all
$totalPrice="SELECT SUM(price) FROM daily";
print"$totalPrice";SELECT SUM(price) FROM daily
Any guidance is appreciated.
Moderator: General Moderators
Code: Select all
$totalPrice="SELECT SUM(price) FROM daily";
print"$totalPrice";Code: Select all
$query="SELECT SUM(price) FROM daily";
$result=mysql_query($query);
print"$result";Code: Select all
$query="SELECT SUM(price) FROM daily";
$result=mysql_query($query);
$myRow=mysql_fetch_array($result);
print"Total expenditure is {$myRow[0]}";There are always better ways to implement solutions. The question is: where do you draw the line? If the criterium is that it's working: you've achieved that. "Better" as such depends what you define as "better".saumya wrote:ya, its working.But is this the right way to do this.Or there is any better method to it?
I Agree, this is an art and needs time to master...patrikG wrote: The point of that would be that you write re-usable code as much as possible, thus reducing the margin for errors considerably, speeding up your work etc. etc. That learning process will take quite some time (and some say, is never finished).