私は、このデータベースに格納するアプリから送信されたデータのこの種を持っていることは、アプリから送信されたデータである: -どのようにアンドロイドアプリから送信されたデータから要素を解析するPHPスクリプトを作成するには?
OrderSummary=[{"Cost":"500","Name":"Wine","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"Wine","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"Wine","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"},{"Cost":"500","Name":"whisky","Quantity":"1","Sellerid":"2","Price":"500"}]
テキストファイルが、できないIAMにデータを格納することが可能になりましたIAMデータベース でそれを格納するためのスクリプトを作成することはこれは私が作成したが、データベースの操作を行うと、データベースに格納し、さらにを続行することができませんでしIAMているPHPスクリプトです: -
<?php
$i=0;
$password="";
$user="root";
$database="shadowpets";
$host="localhost";
$response=array();
$con=mysqli_connect($host,$user,$password,$database)or die("Unable to connect");
if($_SERVER["REQUEST_METHOD"]=="POST")
{
if(isset($_POST['Order']))
{
$data=$_POST['Order'];
$file='text.txt';
$json=json_decode($data,true);
$result=file_put_contents($file,$data);
$response["success"]=1;
$response["message"]="done";
$response["success"]=1;
$response["message"]="done";
}
else
{
$response["success"]=0;
$response["message"]="parameters not correctl formatted";
}
echo json_encode($response);
}
?>
誰もが私に言うことができますどのように私はそれを変更し、それを動作させることができますか?あなたがする必要がどのような
現在のコードには、データベースに何かを挿入しようとするものはありません。あなたは接続を作成しましたが、何もしていません。 –
私の問題は、この配列から単一の文字を読み取ることはできませんが、配列全体を一度に読み取ることができません。 –
@atulkumar実際には、 'OrderSummary'の値にアクセスすることがあなたのコードの' $ data' ? –