Jump to content

adding rows


ngreenwood6

Recommended Posts

<?php
// Make a MySQL Connection

$query = "SELECT type, SUM(price) FROM products GROUP BY type"; 

$result = mysql_query($query) or die(mysql_error());

// Print out result
while($row = mysql_fetch_array($result)){
echo "Total ". $row['type']. " = $". $row['SUM(price)'];
echo "<br />";
}
?>

 

http://www.tizag.com/mysqlTutorial/mysqlsum.php

Link to comment
https://forums.phpfreaks.com/topic/128249-adding-rows/#findComment-664229
Share on other sites

I have this code but it is giving me an error with the syntax.

 

$new_query = "SELECT *,SUM(amount) FROM $banking_table $limit";

 

Any help is appreciated. It worked before I added the sum(amount) portion.

 

EDIT: Maybe I shoudl have read better because he did give the link.

Link to comment
https://forums.phpfreaks.com/topic/128249-adding-rows/#findComment-664240
Share on other sites

I am getting this:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\banking.php on line 86

 

Line 86 is the query

 

and when I echo the query it shows this:

 

SELECT *,SUM(amount) FROM banking LIMIT 10,10 

 

any ideas

Link to comment
https://forums.phpfreaks.com/topic/128249-adding-rows/#findComment-664248
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.