第1次
显示
的输出Msg Ardy Button Msg Ardy Button Msg Ardy Button Msg Ardy Button Msg Ardy Button Msg Ardy Button Msg John Button
<?php
include('connection.php');
$sqlsearch = "SELECT * FROM chat WHERE recievernumber = $empnumnum and Notification = '0' ORDER BY chat_id ASC";
$resultsearch = mysqli_query($conn, $sqlsearch);
if ($resultsearch->num_rows > 0) {
// output data of each row
while($rowsearch = $resultsearch->fetch_assoc()) {
echo "
<tr>
<td>$rowsearch[msg]</td>
<td style='list-style-type: none; color:white;' class='chatlist' data-employeeid='".$rowsearch['employeeid']."' data-fullname='".$rowsearch['user']."'> $rowsearch[user] </td>
<td><button class='chatlist' data-employeeid='".$rowsearch['employeeid']."' data-fullname='".$rowsearch['user']."'>Read</button></td>
</tr>";
}
}
?>
所以我尝试删除多个Ardy Msgs,因此我使用下面的代码。 但结果是。发生的唯一正确的事情是员工ID。因为它有foreach($ id2作为$ value)我在思考我是否可以使用2 foreach来解决它。但我不知道如何。
Msg John Button Msg John Button
第二
<?php
$sqlsearch = "SELECT DISTINCT * FROM chat WHERE recievernumber = $empnumnum and Notification = '0'";
$resultsearch = mysqli_query($conn, $sqlsearch);
if ($resultsearch->num_rows > 0) {
while($rowsearch = $resultsearch->fetch_assoc()) {
$id = $rowsearch['employeeid'];
$id1[] = $id;
$name = $rowsearch['user'];
$name1[] = $name;
$msg = $rowsearch['msg'];
$msg1[] = $msg;
}
$id2 = array_unique($id1);
foreach ($id2 as $value){
echo "
<tr>
<td>".$msg."</td>
<td style='list-style-type: none; color:white;' class='chatlist' data-employeeid='".$value."' data-fullname='".$name."'> $name </td>
<td><button class='chatlist' data-employeeid='".$value."' data-fullname='".$name."'>Read</button></td>
</tr>";
}
}
?>