Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,736 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,197 people online right now. Registration is fast and FREE... Join Now!




Adding money to database ..?

 
Reply to this topicStart new topic

Adding money to database ..?

triplexduplex
post 7 Oct, 2008 - 07:23 AM
Post #1


New D.I.C Head

*
Joined: 4 Apr, 2008
Posts: 19

Okay so I've just began work on my browser game. I have a 'members' table in my database and that is where any signups get stored.

Now I want to add money into the game. To do this, do I add money into the same 'members' table as just another field? Or do I create a whole new table for money .. and what would be the various fields in that? :S

And say I want to give everyone $1000 to start out the game so they get that once they sign up, how can I put this into code so that it works?


Sorry for all the questions, I'm new to this and trying to grasp it.
User is offlineProfile CardPM

Go to the top of the page

Trogdor
post 7 Oct, 2008 - 07:55 AM
Post #2


D.I.C Addict

Group Icon
Joined: 6 Oct, 2006
Posts: 517



Thanked 3 times

Dream Kudos: 125
My Contributions


i assume each member has a 'wallet'.
you can add a field in the members table called wallet.
It can be a float field, or , if you only want to use whole numbers (much more easy!) an integer.

If you want to give all players 1000 when they register you can give the wallet field a default value of 1000. If you then insert a player record, the wallet field will be set on 1000 (unless you sepcify different in the insert query ofcourse)

If you want to give all players 1000 now and overwrite all currently stored values) you do something like update members set wallet=1000
Note the lack of a where clause. Queries like that operate on all your data at once, and can be a disaster when applied wrong.
User is offlineProfile CardPM

Go to the top of the page

triplexduplex
post 13 Oct, 2008 - 08:16 AM
Post #3


New D.I.C Head

*
Joined: 4 Apr, 2008
Posts: 19

Thanks! This helped me understand a lot, and I assume it can be used for stats, and everything else as well.

Unfortunately, I haven't had the time this week to work on it and add in this new code but I'll do it eventually tongue.gif

Thanks once again.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 10:50AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month