I have form data coming in from a UNITY3d WWWForm to my php file. I made a column with the json file type, now I want to store that string in the database. I also want the id field to be the key for the array of the rest of the array.
include('dbconfig.php');
$id= $_POST['ID'];
$servicedate=$_POST['ServiceDate'];
$servicelocation=$_POST['ServiceLocation'];
$mileage=$_POST['Mileage'];
$labor=$_POST['Labor'];
$oilbrand=$_POST['OilBrand'];
$oilprice=$_POST['OilPrice'];
$filterbrand=$_POST['FilterBrand'];
$filterprice=$_POST['FilterPrice'];
$oilfilterpurchaselocation=$_POST['PurchasePlace'];
$arr = array('Service Date' => $servicedate,
'Service Location' => $servicelocation,
'Mileage' => $mileage,
'Labor' => $labor,
'Oil Brand' => $oilbrand,
'Oil Price' => $oilprice,
'Filter Brand' => $filterbrand ,
'Filter Price' => $filterprice ,
'Purchase Place' =>$oilfilterpurchaselocation);
$json= json_encode($id => $arr); //Is this part right?
echo 'Here is our new JSON';
echo $json;
$var= $db->prepare("INSERT into json VALUES(?,?,?,?,?)";
foreach($data as $row)
{
$var->bindParam(1, $row['id']);
$var->bindParam(2, $row['']);
$var->bindParam(3, $row['']);
$var->execute();
}
Is this more of what I need? Thanks!