TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-13-2009, 06:42 PM   #1 (permalink)
The Visitor
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
sils is on a distinguished road
Default mysql update

I'm basicly working with mysql update here.

So i have a table called users and a field named money.
now when user register he also register's an amount of hidden input of money.
input sent to mysql table>money(field)>amount.

now what i want is that if he presses a button, it will decrease his amount of money in the sql.and the button he press will give him something like 500$ for a candy.
so to a field named candy the update will make it (1) and money from the basic amount will get decreased.

can someone help me make the code?
sils is offline  
Reply With Quote
Old 12-04-2009, 07:17 AM   #2 (permalink)
The Acquainted
 
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 137
Thanks: 3
maeltar is on a distinguished road
Default

Ok, been a while since you posted but will give you some pointers...

Break the problem down into manageable pieces, work out the logic first..

We will take it as read that the data is already in the DB..

So logic would be something like...

Get current "money" from DB

Decrease current "money" by "cost of item"

Update new balance in DB

Update/create entry for "item purchased"


Now I would point out at this stage that now it's written out a possible issue can be seen...

You have no way of tracking purchases..

So to that end, you would need another table which you would write the purchases (spelling) into, giving you the ability to track customer purchases.

So, you would have 2 tables....

1/ money, with a unique ID for each customer.

2/ purchases, with a fields holding the customer ID, Item Purchased, Cost, date/time

Anyway thats some thoughts for you if you decide to come back and have a look....
__________________
Thanks... Simon

Sex, Drugs & Linux Rules
Send a message via MSN to maeltar
maeltar is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql update with multi fields sarmenhb Absolute Beginners 1 02-06-2009 10:03 PM
Can you use IGNORE in the update of a mysql row ? codefreek General 5 11-17-2008 12:45 AM
You are subscribed to this thread mysql update with multi fields sarmenhb Advanced PHP Programming 0 11-15-2008 05:00 AM
mysql update with multi fields sarmenhb General 0 11-15-2008 04:19 AM
mysql update statement sarmenhb Absolute Beginners 12 05-20-2008 01:46 AM


All times are GMT. The time now is 03:21 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design