更新MySQL中的多个表失败

时间:2016-06-08 12:54:28

标签: php mysql

嗨,我有一些在表A,B中有多行的信息,我希望用这些信息更新表C,但我不明白为什么我更新表c失败了?

//Table A, B

$result = $db->sql_query("SELECT f.*, p.member_id, p.name
FROM ipb_profile_friends f, ipb_members p
WHERE f.friends_member_id = p.member_id");

while ($row = $db->sql_fetchrow($result)) 
{
    //Table C

    $update = $df->sql_query('UPDATE panel_friends 
                SET id="'.$row['friends_id'].'",
                friends_member_id="'.$row['friends_member_id'].'",
                friends_member_name="'.$row['name'].'",
                friends_friend_id="'.$row['friends_friend_id'].'",
                friends_friend_name="",
                friends_approved="1",
                friends_added="'.$row['friends_added'].'",
                is_ignored="1"');
    $affected_rows = $df->sql_affectedrows($update);

    if ($affected_rows > 0) 
    {   
        echo $row['name'] . "</br>";
    } else {
        echo "fail";
    }
}

0 个答案:

没有答案