开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜