| | |
Using php and html forms to update a mysql database
![]() |
•
•
Join Date: Dec 2007
Posts: 4
Reputation:
Solved Threads: 0
Hi,
Got a bit of a problem with form, i need to be able to update a number in a mysql database using an html form. so basically i need to increment or decrement a number using a text box and a submit button.
heres the code i got:
==============================================
<form name="input" method="get" action="select.php">
Add Stock : <input type="text" name="number1">
<input type="submit" value="+">
</form>
</pre>
<?php
$add = $_REQUEST['number1'];
// update table "goods" contents
$sql =
"UPDATE goods SET stock = stock + $add WHERE id = 1";
"UPDATE stock";
if(!($result = mysql_query($sql,$dblink))) {
print "Fail: query";
exit;
}
?>
===============================================
the code half works but you need to refresh the page and it not updating the database correctly.
also if i made a copy of this code to do the stubtraction it all goes a bit tits up
im guessing there must be a better way for me to do this ?
Someone please help! Merry christmas!
Got a bit of a problem with form, i need to be able to update a number in a mysql database using an html form. so basically i need to increment or decrement a number using a text box and a submit button.
heres the code i got:
==============================================
<form name="input" method="get" action="select.php">
Add Stock : <input type="text" name="number1">
<input type="submit" value="+">
</form>
</pre>
<?php
$add = $_REQUEST['number1'];
// update table "goods" contents
$sql =
"UPDATE goods SET stock = stock + $add WHERE id = 1";
"UPDATE stock";
if(!($result = mysql_query($sql,$dblink))) {
print "Fail: query";
exit;
}
?>
===============================================
the code half works but you need to refresh the page and it not updating the database correctly.
also if i made a copy of this code to do the stubtraction it all goes a bit tits up
im guessing there must be a better way for me to do this ?
Someone please help! Merry christmas!
Welcome to Daniweb. This isnt the right forum to post your code. Post it in php forum. Cheers!
Oh, and one more thing. when you post your code, please use [ code] .. [/ code] tags.
Oh, and one more thing. when you post your code, please use [ code] .. [/ code] tags.
Last edited by nav33n; Dec 19th, 2007 at 8:00 am.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Other Threads in the Community Introductions Forum
- Previous Thread: newcommer
- Next Thread: Looking for an HTML email designer...
| Thread Tools | Search this Thread |
" "delete adsense aladar amatueurgrapicdesigner beginner business c# c#picturebox c++ champlain college contentwriting copywriter correspondence dba deleterectangle dheeraj experiences forensic forum givemetehcodez helloall internet internetmarketing introduction introductory itservices jauhari java lahore.civilengineer market marketing mca multiplerectangle naveen newbie newcomernote newgirl nigeria noob note oil online peertopeervideostreaming pekdi pictureboxselectobject prankerio profanitytest programmer projects research seo seoservices share shiva..... sqlserver stillnew student suthar tester traffic typhoon waliya'sgratituteandrequest. web webcam webdesign welcomenote wllu wolf wordpresstheme






