Jump to content

php/sql query


Wildthing

Recommended Posts

mysql> select rep_surname, AVG(booked) from appointments group by rep_surname;
+-------------+-------------+
| rep_surname | AVG(booked) |
+-------------+-------------+
| nick             |      1.0000 |
| john             |      1.0000 |
+-------------+-------------+
2 rows in set (0.00 sec)
 

But there are 3 rows all all, John has 1 more entry

 

Did I miss something ? I am not real good at this

Link to comment
https://forums.phpfreaks.com/topic/278379-phpsql-query/#findComment-1432305
Share on other sites

Doing my head in

lol

 

 

$result = mysql_query("SELECT rep_surname, COUNT(*) as tot  FROM appointments  GROUP BY rep_surname  order by ASC LIMIT 1");

echo $row['rep_surname'];
---------------------------------------------

 

error in apache log

PHP Notice:  Undefined variable: row in /home/wildthin/public_html/grabbs/test.html on line 10
 

Link to comment
https://forums.phpfreaks.com/topic/278379-phpsql-query/#findComment-1432491
Share on other sites

the error means that you didn't fetch the data from the result set.

 

before you can use php/mysql for your data, you must first learn how to use php/myqsl for any data. you need to read a basic php/mysql tutorial/book so that you understand the steps needed to form an sql query statement, run that query, check if the query executed without any errors, and then fetch any resultant data from that query.

Link to comment
https://forums.phpfreaks.com/topic/278379-phpsql-query/#findComment-1432503
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.