How can i get values from one table and save in other table using event in phpmyadmin

10 replies
I am trying to make a login system for user with following things. I wanted to know user is logging in my website or not.


I create a table "user_record" and i am saving "user last login" value in column "last_login_time"...


Now my question i wanted to create event which check if user last login date is 3 month old then insert "idol/delete" in another table(user_status) column name "status" and i want this event after every 24 hours.
Can any one help me ?
#event #phpmyadmin #save #table #values
  • Profile picture of the author RobinInTexas
    That's not something for phpMyadmin, you need to create a script and a cron job.
    Signature

    Robin



    ...Even if you're on the right track, you'll get run over if you just set there.
    {{ DiscussionBoard.errors[8482429].message }}
  • Profile picture of the author lovefax89
    okay thanks
    {{ DiscussionBoard.errors[8482802].message }}
  • Profile picture of the author indefinitely
    make another field which is related to your source table
    You can try the Select then Insert into command. by the way what database are u using?
    {{ DiscussionBoard.errors[8483309].message }}
  • Profile picture of the author lovefax89
    MySQL normal database with used in hosting phpmyadmin.

    Can you write query for me ?
    {{ DiscussionBoard.errors[8484066].message }}
    • Profile picture of the author seasoned
      Originally Posted by lovefax89 View Post

      MySQL normal database with used in hosting phpmyadmin.

      Can you write query for me ?
      Robin is right. Most, if not all, databases CAN'T schedule! NO variant of standard SQL allows for it. Triggers are triggered ONLY by events in SQL, NOT purely time, so you can't do it there. Even stored procedures need some trigger or must be called.

      THAT means this must be done by an EXTERNAL program triggered by time, and cron triggers programs by time.

      And nobody could give you the SQL without more info. Just for starters, you would have to specify AT LEAST an identifier on the source and target table. Of course, one wonders why you don't have this all in one table. It is a waste of space/effort to not do that. You could change the value to a short integer flag, and save several bytes there. You will probably save dozens on the overhead. So you could have maybe only 5% waiting for deletion and STILL save space, and you wouldn't have to worry about joins to do the deleting.

      Steve
      {{ DiscussionBoard.errors[8485346].message }}
  • Profile picture of the author lovefax89
    Okay so one thing is clear i can do this work using cron job.

    Can any one explain cron job ? and write any simple command for me ?

    I tried in my hosting and i write command echo "hello everyone"; but nothing happened...No email received

    Can you tell me about command ?
    {{ DiscussionBoard.errors[8485593].message }}
  • Profile picture of the author wayfarer
    I don't know how your host does it, but if you have terminal (SSH) access to your host, simply type `crontab -e` to edit your crontab, and read the manual if you need to do anything advanced. A daily cron job would look something like this:

    Code:
    MAILTO=myemail@example.com
    @daily /usr/bin/php /path/to/script.php
    I never use PHP for server administration stuff, but you probably do, so this is just an example. The path to PHP may vary, depending on which flavor of server you have.

    You probably just need to ask your host how to execute a cron job though, most hosts have their own pre-configured way of doing this.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[8488630].message }}
  • Profile picture of the author brutecky
    Instead of making a whole new table what not just make a new field and flag the user as inactive.
    {{ DiscussionBoard.errors[8495199].message }}
  • Profile picture of the author marketwiz
    You can take backup using export options and then you can easily restore using import in another database
    {{ DiscussionBoard.errors[8497806].message }}
  • Profile picture of the author stonecoldmf
    You cannot do it directly scripting in the phpmyadmin you should
    make a php page for it and you can then write script in php to copy
    data according to the conditions.
    {{ DiscussionBoard.errors[8501325].message }}

Trending Topics