我有两个 SQL 表:
- 消息
- 编辑
在新闻表中,我有 2 个列(News_Added 和 News_Updated)。我正在将编辑器 ID 输入到这些列并将它们加入编辑器表的 Ed_ID 以获取编辑器名称。
由于我有 2 个 while 查询,我必须使用 2 个 while 循环,但在 1 个 html 表中。我不知道如何解决这个问题。有什么帮助吗?
echo '<table border="0">
<tr><th>News ID</th><th>Title</th><th>Added By</th><th>Last Edit By</th><th>Action</th</tr>';
$query = mysql_query("SELECT * FROM N1News AS N1
LEFT JOIN A1Editors AS A1 ON N1.N1_Addedby=A1.Ed_ID WHERE N1_Co=$Ed_Co ORDER BY N1_ID LIMIT $show,$limit");
while($row = mysql_fetch_array($query)){
echo '<tr><td align="center">'.$row["N1_ID"].'</td><td><a href="news_edit2.php?n_id='.$row["N1_ID"].'">'.$row["N1_Title"].'</a></td>
<td><a href="news_edit2.php?n_id='.$row['N1_ID'].'"><img src="images/icons/hammer_screwdriver.png" alt="Edit News" /></a><a href="news_del.php?n_id='.$row["N1_ID"].'"><img src="images/icons/cross.png" alt="Delete News" /></a></td><td>'.$row["Ed_Name"].'</td>';
}
$query7 = mysql_query("SELECT * FROM N1News AS N1
LEFT JOIN A1Editors AS A1 ON N1.N1_Lastedit=A1.Ed_ID WHERE N1_Co=$Ed_Co ORDER BY N1_ID LIMIT $show,$limit");
while($row7 = mysql_fetch_array($query7)){
echo '<td>'.$row7["Ed_Name"].'</td>';
}