我創建了一個表消息有柱USER_ID,message_sender,message_receiver,message_receiver_id如何在PHP中的MySQLi選擇多列
查詢,如下
線1的結果:2 ABOL阿狼3
第2行:2 ABOL MAK 4
3號線:3阿朗ABOL 2
線路4:3阿郎麥4
我希望顯示有阿狼記錄是1,3,4號線所有查詢。我設法只顯示一行3,4但不能顯示1行,這裏的代碼
<?php
include("includes/connections.php");
function displaymessagesprofile(){
global $connect;
global $user_id;
$get_id = $_GET['message_receiver_id'];
$sql_message = "SELECT * FROM messages WHERE user_id='$user_id' OR message_receiver_id='$get_id'";
$get_message = mysqli_query($connect, $sql_message);
if($get_message && mysqli_num_rows($get_message) > 0){
while($row_message = mysqli_fetch_array($get_message)){
$user_id = $row_message['user_id'];
$message_sender = $row_message['message_sender'];
$message_receiver = $row_message['message_receiver'];
$message_receiver_id= $row_message['message_receiver_id'];
//to display message sent and received by the user logged in
echo "<div id='message_wrap'>
<p>$message_sender</p>
<p>$message_receiver</p>
<p>$message_receiver_id</p>
</div>
";
}
mysqli_free_result($get_message);
}
else{
echo "No message yet";
}
}
?>
錯誤下面顯示:
注意:未定義指數:message_receiver_id
你確定你有'message_receiver_id'變量我你的網址? – Irvin
是的。當然。未定義的索引。我不知道爲什麼 – Jamilah
行$ get_id = $ _GET ['message_receiver_id']; – Jamilah