1 Replies - 335 Views - Last Post: 16 September 2012 - 10:14 PM Rate Topic: -----

#1 cooldude511  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-September 12

Working with user sessions

Posted 16 September 2012 - 06:40 PM

Hi, I am building a gaming web site with user accounts where users have coins as assets which they can use to bet on the games. When a user is logged in, I want to connect the entire betting process to his account in database such that whenever he bets, only his account is updated in database and other users account remain the same. How do I do that?
Is This A Good Question/Topic? 0
  • +

Replies To: Working with user sessions

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4333
  • View blog
  • Posts: 12,128
  • Joined: 18-April 07

Re: Working with user sessions

Posted 16 September 2012 - 10:14 PM

You do that by running SQL queries from PHP. For instance, if they bet five coins and loses you run a query like

update users set coins = coins - 5 where userid = 3



Here we are saying "Update the users table, set the column 'coins' to the value of 'coins' minus 5 and do this for the user who has the id of '3'"

As you create user accounts, you assign them an id value that is unique. You can then create update queries which will update that account using their ID and this will update only that record, not others.

Look up SQL update queries for more information. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1