<html>
<body>
<form name="form" method="post" action="test.php">
Number: <input type="text" name="number"><br />
<input type="submit" name="add" value="+"><input type="submit" name="subtract" value="-">
</form>
</body>
</html>
<?php
$conn=mysql_connect("localhost","username","password");
mysql_select_db("dbname");
if(isset($_POST['add'])){
$add=$_POST['number'];
$query="update goods set stock=stock+$add where id=1";
mysql_query($query) or die("Cannot update");
}
if(isset($_POST['subtract'])){
$subtract=$_POST['number'];
$query="update goods set stock=stock-$subtract where id=1";
mysql_query($query) or die("Cannot subtract");
}
?>
Umm.. you forgot to put your code in [ c o d e ] [ / c o d e ] tags. Anyways, I hope this helps.
Last edited by nav33n; Dec 19th, 2007 at 8:15 am.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*