Jiraiya Posted November 29, 2008 Share Posted November 29, 2008 i have a script to that i want to count all the users from a table and display the total number of people in that group for example: Group A: 3 Group B: 6 Group C: 20 Group D: 204 something like that there is the script im not sure if its right <?php // Make a MySQL Connection $query = "SELECT village, COUNT(user) FROM members GROUP BY village"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are ". $row['COUNT(user)'] ." ". $row['village'] ." items."; echo "<br />"; } \ // generate and execute query $query = "SELECT * FROM townranks ORDER BY sk DESC"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if records present if (mysql_num_rows($result) > 0) { // iterate through resultset // print article titles while($row = mysql_fetch_object($result)) { ?> <tr> <td><?php echo $row->townname; ?></td> <td><?php echo $row->hp; ?></td> <td><?php echo $row->sk; ?></td> <td><?php echo $row->kage; ?></td> <td><?php echo $row->people; ?></td> </tr> <?php } } // if no records present // display message else { ?> <p>No press releases currently available</p> <?php } // close database connection mysql_close($connection); ?> </table> <center><H3><li><a href="http://narutotalesofthesannin.com/player.php">To Your Profile</a></li> </body> </html> Link to comment https://forums.phpfreaks.com/topic/134715-php-script-help/ Share on other sites More sharing options...
trq Posted November 29, 2008 Share Posted November 29, 2008 there is the script im not sure if its right Does it work? Link to comment https://forums.phpfreaks.com/topic/134715-php-script-help/#findComment-701479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.