0
user_id
可以在replies
表中找到,但也可以在profiles
表中找到。配置文件表具有real_name
列。如何從另一個表中的while循環內的表中獲取數據?
下面我得到所有 s的具體article_id
。我的問題是,如何回覆保存在profiles
表中的評論者的real_name
?
我認爲這是表現。
$replies = mysql_query("select * from replies where article_id = '$row[id]' order by timestamp desc");
while($reply = mysql_fetch_assoc($replies)) {
I can echo the comments from the replies table, but how do I echo the real_name of each?
}
加入配置文件表?類似於'select p.real_name,r。* from reply as r join profiles as p on r.profileid = p.profileid where article_id ='$ row [id]'order by timestamp desc' might have to update the 'profileid'列名 – chris85 2015-04-04 15:53:12
還可以查看[mysqli](http://php.net/manual/en/book.mysqli.php)或[PDO](http://php.net/manual/en /ref.pdo-mysql.php)作爲[mysql_](http://php.net/manual/en/function.mysql-connect.php)函數從PHP 5.5.0開始已棄用 – TheSk8rJesus 2015-04-04 16:24:47