I am trying to do a php code that subtract -1 of quantity stored in a mysql table named ''caffe''.
The table start with 10 and if php is executed with value caffe a quantity in table will be updated.
Will be good some lines of code so i can understand how it work.
- read value from url:
http://mypage/getdata.php?value=caffe
- read value from database table
caffe
- subtract -1 from the table
- update the value of mysql table
caffe
<?
$servername = "localhost";
$username = "xxx";
$password = "";
$database = "my_ufficina";
//creating a new connection object using mysqli
$conn = new mysqli($servername, $username, $password, $database);
//if there is some error connecting to the database
//with die we will stop the further execution by displaying a message causing the error
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//if everything is fine
$txt = $_GET['value'];
if ($txt == caffe)
$count = 1;
echo $count;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…