I used this article , did everything as it says, but I still need to know how to make a registered name for registered users who is online; but the registration system that I used.

    1 answer 1

    Make a users table with a list of all users. In addition to the id, login, pass fields , add the last_visit field to the type of the timestamp field, write the current_timestamp value by default, you can specify this in the database when creating the field. Now, in order to calculate how many people are online and get their data, we make a request:

    $time=time(); $sql_sel='SELECT COUNT(t_user.id) AS `online_count`,t_user.* FROM `users` AS `t_user` WHERE last_time > $time-$wine'; 

    In this way, you will receive in one request the quantity online and their data. I think that it is not necessary to create another table for this purpose, specifically to calculate the amount online and load the database with unnecessary queries. just add one field to the existing user database and make such a request

    • The error comes out - paloshmaxpro
    • Error SQL query: CREATE TABLE host1235767 . qwerty ( qwerty DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP) ENGINE = MYISAM; MySQL response: # 1067 - Invalid default value for 'qwerty' - paloshmaxpro
    • Go to phpmyadmin, choose your table, select the structure tab. At the bottom there is an add field to the table, take to the end of the table. Click on the box - last_time, type - timestamp, default - current_timestamp. I apologize, I specified an incorrect field type, I don’t need a datetime, but the timestamp CREATE TABLE host1235767.qwerty (qwerty TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP) ENGINE = MYISAM; - Barton
    • I tried but it didn't work - paloshmaxpro
    • What exactly did not work out right now? add a field or make a selection? Read about the mysql data types - mysql.ru/docs/man/DATETIME.html - Barton