Hi, i was wondering how to update a table in my mysql database when a user checks a radio button then clicks submit.
the table id need to update is called 'points'. It is a table that will be storing users points on a site im developing.
The update would deduct a certain amount of points from that users total points score that i will set in the value of my radio button.
Anyone know the sql part of it?
Thanks
mysql UPDATE in submit form
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
SQL != PHP 
Databases.

[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
Re: mysql UPDATE in submit form
Without more information, I can only give you a pseudo-query:LHOOQ wrote:Hi, i was wondering how to update a table in my mysql database when a user checks a radio button then clicks submit.
the table id need to update is called 'points'. It is a table that will be storing users points on a site im developing.
The update would deduct a certain amount of points from that users total points score that i will set in the value of my radio button.
Anyone know the sql part of it?
Thanks
Code: Select all
UPDATE tablename SET points = points - $point_value WHERE username = '$user_name';
Thanks for your reply, i know nothing about mysql myself.
Sorry for being vague.
This is what i am having trouble with....
On my site i have this...
<form name="input" action="" method="post"></font>
<input type="radio" name="cost" value="{%USER_COST%}" checked="checked">
<input type ="submit" value ="Buy!">
</form>
What i dont know is where to put the UPDATE part in order to deduct the points upon hitting submit
Any clue???
Sorry for being vague.
This is what i am having trouble with....
On my site i have this...
<form name="input" action="" method="post"></font>
<input type="radio" name="cost" value="{%USER_COST%}" checked="checked">
<input type ="submit" value ="Buy!">
</form>
What i dont know is where to put the UPDATE part in order to deduct the points upon hitting submit
Any clue???
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Your UPDATE will have to take place in the code. If you are a total newbie to PHP and MySQL, then this might be a little advanced for you at this stage. In fact, if you don't know what you are doing, you could possibly do your database harm. How much experience do you have with PHP and MySQL and how much code have you written?
I know quite alot of php, but very little mysql.
I have no trouble with writing most things html off memory, and some things php.
I have a similar code that does the same function, but its totally different (if you know what i mean) + someone else coded it.
I know some mysql queries and what they do/how they work. I'm just lost when it comes to knowing where to place them in order for them to execute properly.
I have no trouble with writing most things html off memory, and some things php.
I have a similar code that does the same function, but its totally different (if you know what i mean) + someone else coded it.
I know some mysql queries and what they do/how they work. I'm just lost when it comes to knowing where to place them in order for them to execute properly.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Think of your PHP code as a series of logical instructions. When you code, you are basically writing into a document rules for processing something. As you want things to happen, write them into the code in that way. It will flow logically and be a lot easier to edit later on if needed.
For your purposes, once the form is submitted (to whatever page you name in the 'action' element of the <form> tag) the action page will need to have PHP code on it that receives the passed data, validates it and then hits the database with some update instructions (queries). That is the logical flow of what you want to do.
For your purposes, once the form is submitted (to whatever page you name in the 'action' element of the <form> tag) the action page will need to have PHP code on it that receives the passed data, validates it and then hits the database with some update instructions (queries). That is the logical flow of what you want to do.