0
button to add one to database total
Explorer
,
/t5/dreamweaver-discussions/button-to-add-one-to-database-total/td-p/803505
Apr 25, 2006
Apr 25, 2006
Copy link to clipboard
Copied
HI Folks,
I'm new to all of this PHP business but I'm working though a project to create a quiz site. It will never see the light of day but I thought it would help me learn.
I have set up a MySQl table with 3 rows - id, teamname and teamscore.
Each team name to appears at the top of the page with the current score underneath. What I would like to add is a button or link below that which when clicked adds one to the teamscore.
Can anyone point me in the right direction?
Cheers
Tubby
I'm new to all of this PHP business but I'm working though a project to create a quiz site. It will never see the light of day but I thought it would help me learn.
I have set up a MySQl table with 3 rows - id, teamname and teamscore.
Each team name to appears at the top of the page with the current score underneath. What I would like to add is a button or link below that which when clicked adds one to the teamscore.
Can anyone point me in the right direction?
Cheers
Tubby
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/dreamweaver-discussions/button-to-add-one-to-database-total/m-p/803506#M114774
Apr 25, 2006
Apr 25, 2006
Copy link to clipboard
Copied
Hi, you would need some update sql similar to the following:
UPDATE table_name SET teamscore = teamscore + 1;
hope this points you in the right direction
UPDATE table_name SET teamscore = teamscore + 1;
hope this points you in the right direction
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
mac-in-the-mountains
AUTHOR
Explorer
,
/t5/dreamweaver-discussions/button-to-add-one-to-database-total/m-p/803507#M114775
Apr 26, 2006
Apr 26, 2006
Copy link to clipboard
Copied
Thanks for that.
On that basis the code should be
UPDATE teamnames
SET teamscore= teamscore +1;
but how do I turn that into a button on the page?
I've tried using a form and including this code as a hidden field but it didn't work and I'm sure that's too much of a complicated method?
Can you (or anyone else) suggest a better way of doing it so that I can simply click and button or even textlink to apply the code?
Cheers
Tubby
On that basis the code should be
UPDATE teamnames
SET teamscore= teamscore +1;
but how do I turn that into a button on the page?
I've tried using a form and including this code as a hidden field but it didn't work and I'm sure that's too much of a complicated method?
Can you (or anyone else) suggest a better way of doing it so that I can simply click and button or even textlink to apply the code?
Cheers
Tubby
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
mac-in-the-mountains
AUTHOR
Explorer
,
/t5/dreamweaver-discussions/button-to-add-one-to-database-total/m-p/803508#M114776
Apr 27, 2006
Apr 27, 2006
Copy link to clipboard
Copied
Can anyone out there help me. I've still struggling with this
one
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/dreamweaver-discussions/button-to-add-one-to-database-total/m-p/803509#M114777
Apr 27, 2006
Apr 27, 2006
Copy link to clipboard
Copied
You had the right idea to use a form,
use the update record wizard, this will generate the update sql required at the top of your page. You will need to modify this code slightly by adding +1 .
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE table_name SET temascore= broker_rating + 1",
GetSQLValueString($_POST['teamscore'], "int"));
Your form hidden field should be similar to
<input type="hidden" name="teamscore" value="<?php echo $row_nameofrecordset['teamscore']; ?>">
all this is assuming you havea field in your db named teamscore.
hope this helps a little
use the update record wizard, this will generate the update sql required at the top of your page. You will need to modify this code slightly by adding +1 .
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE table_name SET temascore= broker_rating + 1",
GetSQLValueString($_POST['teamscore'], "int"));
Your form hidden field should be similar to
<input type="hidden" name="teamscore" value="<?php echo $row_nameofrecordset['teamscore']; ?>">
all this is assuming you havea field in your db named teamscore.
hope this helps a little
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
mac-in-the-mountains
AUTHOR
Explorer
,
LATEST
/t5/dreamweaver-discussions/button-to-add-one-to-database-total/m-p/803510#M114778
Apr 27, 2006
Apr 27, 2006
Copy link to clipboard
Copied
Fantastic !!!!
It works and I've even added anoher button for "minus one point".
Thanks very much for taking the time to help.
Tubby
It works and I've even added anoher button for "minus one point".
Thanks very much for taking the time to help.
Tubby
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

