If there is information in one filed then update another..

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
oskare100
Forum Commoner
Posts: 80
Joined: Sun Oct 29, 2006 5:47 am

If there is information in one filed then update another..

Post by oskare100 »

Hello,
I have a few fileds in my database where I want to save information about which IP addresses my members have when they login.

In one table I've fields for the username, password, member group and so on. Then I've a few fields with the names login_ip_1, login_ip_2, login_ip_3, login_ip_4 and login_ip_5 where I want to save the IP numbers the member used when he/she loged in the four last times.

So basicly what I need to do it that if let say a user log in with one IP the ip is saved in the login_ip_1 field. If then the user logs in again with another IP I want that one to be saved in login_ip_2 and so on until login_ip_5 and when login_ip_5 is filled I want it to send an email.. but that last part with the reporting shouldn't be a problem.

Best Regards
Oskar R
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The whole thing is possible with a simple UPDATE query, except for the last part. Knowing when all five have data in them and an email needs to be sent is the job of a SELECT query.
Post Reply