Forum Moderators: coopster & phranque

Message Too Old, No Replies

Avoiding DB double Query

An 'is this possible question'

         

Nick_W

7:12 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I would like to record in MySQL how many times a user has logged in.

If the table (purely an example) looked like this:

¦id¦logins¦

I can only think of making one call to get the current login, then adding '1' to it and making another call to update the table.

Cookies would be very unreliable I'm thinking so, is there another way?

Many thanks

Nick

Birdman

7:21 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



UPDATE userlogins SET logins = logins +1

Try that, Nick. It should work.

Nick_W

7:22 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But it doesn't know what logins is does it?

Nick

Gibble

7:23 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



update loginCounter set logins = logins + 1 where id = 'myid'

Birdman

7:29 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right, I forgot that part :o Typing too fast.

Nick_W

7:34 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, it works perfectly guys ;)

Must be something lacking in my education. I thought it would have no knowledge of the current value?

Many thanks, that's really a really neat way of doing it!

Nick