0

我有 2 个表用户和消息:用户包含id, fullname, email,password
消息包含id, sender, receiver,link

我想阅读接收者(用户id)的所有链接,其中它等于email,以及echo发送者和接收者的全名以及链接。

有人请,我对此有点陌生?

$sql = mysql_fetch_assoc("SELECT m.sender,m.receiver, m.link, u.fullname, u.email 
                         FROM `users` AS u 
                         JOIN `messages` AS m ON m.receiver = u.id 
                         WHERE u.email = '$email'");

echo $sql['sender'];
4

1 回答 1

0
$query = "SELECT m.sender,m.receiver, m.link, u.fullname, u.email 
                     FROM `users` AS u 
                     JOIN `messages` AS m ON m.receiver = u.id 
                     WHERE u.email = '" . $email . "'";

$result = mysql_query($query);
while($row = myslq_fetch_assoc($result)) {
    echo $row['sender'];
}
于 2013-02-03T18:31:42.537 回答