This is y code. I wanted to send data as JSON format from JS file to php. So php can read and update all prices in once. Is it possible?
<?php
$mysql = mysqli_connect("localhost","root","","db_prices") or die("Error " . mysqli_error($connection));
$data = file_get_contents("php://input");
$jsonData = json_decode($data, true);
foreach($jsonData['prices'] as $key => $value) {
if($value) {
//how to use json array to insert data in Database
mysqli_query($mysql,"UPDATE prices SET price = '".$value."' WHERE price = '". $key ."' LIMIT 1");
}
}
?>
This is y code. I wanted to send data as JSON format from JS file to PHP. So PHP can read and update all prices in once. Is it possible?