Counting entries in database table


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $con = mysql_connect("localhost", "root", "root");
  3. if (!$con) {
  4. die('Could not connect: ' . mysql_error());
  5. }
  6.  
  7. mysql_select_db("sfcommunity", $con);
  8.  
  9. $query = 'SELECT COUNT(*) FROM `jos_users_info`';
  10. $result = mysql_query($query) or die('Sorry we could not count the number of users: ' . mysql_error());
  11. $numberofusers = mysql_result($result, 0);
  12. mysql_close($con);
  13. echo "$numberofusers";
  14. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.