我有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'];
答案 0 :(得分: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'];
}