How do I put live membership figures on my site, I have mysql databases, any scripts I can get to do the job?
I know from my databases I have x members but how do I get that figure on my index page in something like "x members and growing" and have it updating every time I get a new member. Understand?
You just have to write up a query and put it in a php page, you'll need to know the table and column name in the database to do this. Here's a basic query tutorial: http://students.nebrwesleyan.edu/tutorial/php/page7.php If you need help, when I get back I can help you write it up, but I will need some info first.
Thanks for that info am justing trying to find where in the database to query. Thanks for that tut too. Now to see if I can get it working!
You have several ways of doing this with simpel sql : Select max(UserID) from Users; if you are using auto_increment on Users this will work fine(if you remove a user it will not show the removed user Otherwise you can use select count(Username) from Users; This way you cound more actual number of users (if you remove users this will count the actual number of users) Hope this helps a bit
I can't get it to work, is the tut above accurate? Can someone post a example of working code (obviously with different variables to protect their privacy)
Well...here's what I've came up with. I would strongly suggest reading a tutorial or a book about PHP & MySQL Integration. //Build the connection and select the database $link = mysql_connect(HOST, USER, PASS) or die('Could not connect: ' . mysql_error()); //build MySQL Link mysql_select_db(DB) or die('Could not select database'); //select database //Create the query string $Query = "SELECT COUNT(UserID) AS UserCount FROM UsersTable"; //execute the query $Result = mysql_query($Query) or die("ERROR:" . mysql_error()); //put the data from the one returned row into an array $Row = mysql_fetch_assoc($Result); //Take data from the UserCount field in that array and assign it to the UserTotal variable $UserTotal = $Row['UserCount']; //Use the variable $UserTotal to display the number of users, maybe something like: echo "$UserTotal users and growing every day!"; PHP: