Sedric Heidarizarei Sedric Heidarizarei -4 years ago 146
JSON Question

echo json array in a phpMyAdmin Column VIA PHP

Hello I have JSON rows like This:

//THis is one of My Rows
{"id":"40","answer":["Number 3"],"type":"g"}]

How Can I echo

db Name: array
Table Name: user_survey_start
JSON row Name: survey_answers
, This is my code:

// 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


Answer Source

First I Need To Select My Primary Key

$sql="SELECT `survey_answers`,us_id FROM `user_survey_start`";

Then Put Value To ID

$id[] = $data['id'];

After That

$sql1="update user_survey_start set id2='$ids' where us_id=".$row[1];//run update sql
echo $sql1."<br>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download