gavin1512 Posted March 12, 2008 Share Posted March 12, 2008 Good Afternoon, I am having a slight issue displaying the results of a count query. I have tested it in the SQL section of PHPmyAdmin and the query runs fine and gets 5 results and the appropriate counts. Here is my SQL Query~: $query="select COUNT(orderid),employee.username from orders, employee where employee.username = orders.username AND `date` BETWEEN '" . $date1 . "' AND '" . $date2 . "' Group BY orders.username"; $result=@mysql_query($query,$connection) or die("Unable to perform query<br>$query"); I am displaying the results with: <?php while($row= mysql_fetch_array($result)) { ?> <tr> <td> </td> <td><?php echo $row['employee.username']?></td> <td><?php echo $row['COUNT(orderid)'] ?></td> <td> </td> <td> </td> </tr> <?php } ?> I have tried removing the date function but that does not seem to be the problem. Any assistance would be much appreciated Link to comment https://forums.phpfreaks.com/topic/95800-problem-displaying-results-of-count-query/ Share on other sites More sharing options...
soycharliente Posted March 12, 2008 Share Posted March 12, 2008 Try saying: COUNT(orderid) as num_ids Then: $row['num_ids'] Whenever I use COUNT or AVG or something, I tend to use AS and name me a new variable to reference it with. Link to comment https://forums.phpfreaks.com/topic/95800-problem-displaying-results-of-count-query/#findComment-490439 Share on other sites More sharing options...
kenrbnsn Posted March 12, 2008 Share Posted March 12, 2008 And the problem is? Link to comment https://forums.phpfreaks.com/topic/95800-problem-displaying-results-of-count-query/#findComment-490440 Share on other sites More sharing options...
gavin1512 Posted March 12, 2008 Author Share Posted March 12, 2008 cheers Charlie all sorted Link to comment https://forums.phpfreaks.com/topic/95800-problem-displaying-results-of-count-query/#findComment-490682 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.