John Perry wrote:
Ok brain fart here. How to I "echo" the value of the sql statement:
$sql="SELECT SUM(sales) FROM db GROUP BY id ORDER BY sales DESC limit 0,10";
How would I display the information with the sum amount and the salesmans name?
Using PHP I assume....and which db server? Assuming mysql (you're using LIMIT above):
Here's the manual link:
http://www.php.net/manual/en/ref.mysql.php
In a nutshell ('cause you really should check the manual), you ...
1.Connect to db:
<?
$link = mysql_connect("localhost", "mysql_user", "mysql_password")
or die("Could not connect");
?>
- choose a database:
<?
mysql_select_db("databasename", $link)
?>
- Set a db result to your query:
$result = mysql_fetch_row($your_query);
- "echo" out the data:
while ($row = mysql_fetch_row ($result))
{
echo "$row[0]<br>\n";
}
- Close db connection:
mysql_close($link);