Jon12345 Posted December 20, 2006 Share Posted December 20, 2006 I have this query:SELECT kid, count(action)from visitor_loggroup by kidHow do I display the kid and count(action) column?Is it like this?[code]echo "<td>".$row['kid']."</td>";echo "<td>".$row['count']."</td>"; [/code]Thanks,Jon Link to comment https://forums.phpfreaks.com/topic/31416-showing-columns/ Share on other sites More sharing options...
craygo Posted December 20, 2006 Share Posted December 20, 2006 well you have to do more than that[code]<?php$sql = "SELECT kid, count(action) AS countfrom visitor_loggroup by kid";$res = mysql_query($sql) or die (mysql_error());while($row= mysql_fetch_assoc($res)){ echo "<tr> <td>".$row['kid']."</td> <td>".$row['count']."</td> </tr>";}?>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/31416-showing-columns/#findComment-145433 Share on other sites More sharing options...
Jon12345 Posted December 20, 2006 Author Share Posted December 20, 2006 That solved it for me. Thank you! I didn't have count(action) AS count. Link to comment https://forums.phpfreaks.com/topic/31416-showing-columns/#findComment-145493 Share on other sites More sharing options...
Jon12345 Posted December 20, 2006 Author Share Posted December 20, 2006 How would I modify the query string so that not only does it group by kid, but I also have a column that shows the number of kids that were grouped, if that makes sense.Any ideas how? Link to comment https://forums.phpfreaks.com/topic/31416-showing-columns/#findComment-145502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.