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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 12, 2008 Share Posted March 12, 2008 And the problem is? Quote Link to comment Share on other sites More sharing options...
gavin1512 Posted March 12, 2008 Author Share Posted March 12, 2008 cheers Charlie all sorted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.