...

View Full Version : Please Please Help me with this sum function



Binod Bista
12-15-2010, 04:21 PM
i want to get the sum of partysize printed but i get follow error

Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\ha\bestilling2.php on line 96




Here is my code




$query = "SELECT Partysize, SUM( Partysize ) AS PartySizesum
FROM booking
WHERE BookDate = '2010-12-31'";


$row =mysql_fetch_array($query);
echo $row['PartySizesum'];

Rowsdower!
12-15-2010, 07:02 PM
It looks like you skipped a step. Try this:


$query = "SELECT Partysize, SUM( Partysize ) AS PartySizesum FROM booking WHERE BookDate = '2010-12-31'";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
echo $row['PartySizesum'];
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum