<?php
$con=mysqli_connect("localhost","xx","xx","xx");
$con2=mysqli_connect("localhost","xx","xx","xx");
$name = $_POST["name"];
$state = $_POST["state"];
$feedback = $_POST["feedback"];
//$ad_id= $_POST["ad_id"];
$rate= $_POST["rate"];
$ad_rating = $_POST["ad_rating"];
$ad_id= $_POST["ad_id"];
$statement = mysqli_prepare($con, "INSERT INTO user_feedback(name, state, feedback, ad_id, rate) VALUES (?,?,?,?,?)");
$statement2 = mysqli_prepare($con, "UPDATE post_ads SET ad_rating= $ad_rating + $ad_rating WHERE ad_id= ?");
mysqli_stmt_bind_param($statement, "sssss", $name, $state, $feedback, $ad_id, $rate);
mysqli_stmt_bind_param($statement2, "ss", $ad_rating, $ad_id);
mysqli_stmt_execute($statement);
mysqli_stmt_close($statement);
mysqli_stmt_execute($statement2);
mysqli_stmt_close($statement2);
mysqli_close($con);
?>
I currently doing a mobile apps and need to parse data into database and here is my php code.
i currently have ad_rating attribute inside my database table and i have attach the image link here.
My problem is that every time i update new value of ad_rating, how should i add it with previous one? Example ad_rating = 4, so when i try to do a new request by sending ad_rating = 3, i want to add it with my previous ad_rating value which is 4, so the value inside ad_rating become 7.