Update mysql table with data from json
I recently asked this question. While loop together with foreach
My problem was resolved with this
$result = mysql_query("SELECT id FROM people");
$id = array($row['id']);
while($row = mysql_fetch_array($result))
{
echo $json->$row['id']->person->{'name'}. '<br />';
echo $json->$row['id']->person->{'age'}. '<br />';
}
Currently this code only echo's the result set. What I really want to do is replace this echo with mysql u开发者_如何学编程pdate query. That will update the same table used in the select query.
This table called people has fields id, name and age.
How can I update this table with these results?
Thanks again
mysql_query("UPDATE people SET name='".$json->$row['id']->person->{'name'}."' && age='".$json->$row['id']->person->{'age'}."'");
Although I would suggest PDO rather than mysql_ functions
精彩评论