Hallo Ich habe JSON Zeilen wie diese:Echo Json-Array in einem phpMyAdmin Spalte VIA PHP
//THis is one of My Rows
[{"id":"26","answer":[{"option":"3","text":"HIGH"}],"type":"a"},
{"id":"30","answer":[{"option":"3","text":"LOW"}],"type":"b"},
{"id":"31","answer":[{"option":"3","text":"LOW"}],"type":"c"},
{"id":"32","answer":[{"option":"3","text":"HIGH"}],"type":"d"},
{"id":"33","answer":[{"option":"3","text":"HIGH"}],"type":"e"},
{"id":"34","answer":[{"option":"3","text":"HIGH"}],"type":"f"},
{"id":"40","answer":["Number 3"],"type":"g"}]
Wie kann ich echo id
answer
type
,
und db Name: array
Table Name: user_survey_start
JSON row Name: survey_answers
, Dies ist mein Code:
<?php
$con=mysqli_connect("localhost","root","","array");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// $sql="SELECT survey_answers->"$.id" AS `twitter` FROM user_survey_start";
$sql="SELECT survey_answers FROM user_survey_start";
if ($result=mysqli_query($con,$sql))
{
// Fetch one and one row
while ($row=mysqli_fetch_row($result))
{
printf ("%s \n",$row[0]);
}
// Free result set
mysqli_free_result($result);
}
mysqli_close($con);
?>
Und was ist das Problem? Auch für die letzte Zeile in JSON 'Number 3' wird String –
Ich möchte mit meiner Tabelle Spalte verbinden, und Echo JSON Zeilen automatisch, aber weiß nicht, wie kann ich das tun, Ja ja ich mag That String auch zu beheben. Vielen Dank –
speichern Sie JSON im Spaltennamen 'survey_answers'. – gaurav