Jump to content

MYsql. im new


SpOrTsDuDe.Reese

Recommended Posts

hello im new to using mysql databases. i have a website : www.gameyin.com : it is a new site so dont make fun of it. but if you look in bottom left screen i need to know how to show the active users ( i dont know if thats mysql but w.e. and i need to know how to access the databases in my website so that when someone tries to login, it will access the data from mysql. any ideas? script code?

Link to comment
Share on other sites

Check the w3schools site to see how to use PHP to connect with a MySQL database:http://www.w3schools.com/php/php_mysql_intro.aspto track users logged in, you will want to store a timestamp in the database that you update on every page when you check if the user is logged in. To display how many people are logged in, you get the number of people from the database who have a timestamp within the past 10 minutes or so.

Link to comment
Share on other sites

allright thanks dude. well i still dont know hwo to do this. they gave me a codesql = 'ALTER TABLE `Members` CHANGE `First` `First` VARCHAR(15) CHARACTER SET hp8 COLLATE hp8_english_ci NOT NULL, CHANGE `Last` `Last` VARCHAR(15) CHARACTER SET hp8 COLLATE hp8_english_ci NOT NULL, CHANGE `User` `User` VARCHAR(10) CHARACTER SET hp8 COLLATE hp8_english_ci NOT NULL, CHANGE `Pass` `Pass` VARCHAR(8) CHARACTER SET hp8 COLLATE hp8_english_ci NOT NULL, CHANGE `Email` `Email` VARCHAR(20) CHARACTER SET hp8 COLLATE hp8_english_ci NOT NULL';dunno what the ###### that is. well i do but i dont know where i would put it. w3schools isnt lots of help -.-

Link to comment
Share on other sites

All that statement does is alter the field properties for the table. You wouldn't have a statement like that run in a normal page, you would run that once to set up the database like it needs to be set up, or set those properties yourself. From what that statement shows, there are columns called "First", "Last", "User", "Pass", and "Email". You need to add a timestamp field to record the time of last activity for the user, and on every page (for example, when you check if the user is logged in), you update that timestamp field with the current time. Then to display how many people are online you get the number of records from the database where the timestamp is within the last 5 minutes, or 10 minutes, or 15 or whatever.

Link to comment
Share on other sites

  • 2 weeks later...

If you have an integer field calld timestamp, you would update it for the users like this:mysql_query("UPDATE Members SET timestamp=" . time() . " WHERE User='your username'");To get the users who have been online within the past 10 minutes, you would do this:$result = mysql_query("SELECT * FROM Members WHERE timestamp >= " . time() - (60 * 10));

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...