<?php
$query_announcement = mysql_query("SELECT * FROM announcement");
$get_announcement = mysql_fetch_assoc($query_announcement);
?>
<?php
if(mysql_num_rows($query_announcement) > 0){
$row = mysql_num_rows($query_announcement);
for($x = 1; $x<= $row; $x++){
$html = '<tr>';
$html .= '<td>'.$get_announcement['id'].'</td>';
$html .= '<td>'.$get_announcement['announce_name'].'</td>';
$html .= '<td>'.$get_announcement['announce_description'].'</td>';
$html .= '<td>'.$get_announcement['announce_location'].'</td>';
$html .= '<td>'.date('M d,Y', strtotime($get_announcement['date_start'])).'</td>';
$html .= '<td>'.date('M d,Y', strtotime($get_announcement['date_end'])).'</td>';
$html .= '<td>'.date('M d,Y', strtotime($get_announcement['date_added'])).'</td>';
$html .= '<td width="15%">
<button type="button" class="btn btn-default" title="Edit"><span class="fa fa-pencil"></span></button>
<button type="button" class="btn btn-default" title="Delete" ><span class="fa fa-trash-o"></span></button>
</td>';
$html .= '</tr>';
echo $html;
}
}
else{
echo '<tr><td colspan="8" align="center"><h3>No Announcement</h3></td></tr>';
}
?>
/这是我的代码,但是当我运行它时,我只会得到具有相同ID的公告,而不是我创建的所有公告。请帮助谢谢
最佳答案
您一次只能提取数据
for($x = 1; $x<= $row; $x++){
$get_announcement= mysql_fetch_assoc($query_announcement);
关于php - 从表中全选并显示结果mysql,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30172636/