![]() |
| ||
| Using php and html forms to update a mysql database 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! |
| ||
| Re: Using php and html forms to update a mysql database <html> Umm.. you forgot to put your code in [ c o d e ] [ / c o d e ] tags. Anyways, I hope this helps. |
| ||
| Re: Using php and html forms to update a mysql database Thanks mate that sorted it for me! |
| ||
| Re: Using php and html forms to update a mysql database :) you are welcome! |
| All times are GMT -4. The time now is 9:46 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC