我有一个显示所有数据的功能,在表格中。行返回的数量是正确的(基于编辑n删除按钮),但不显示该值。
public function viewAll()
{
$sql = "SELECT 'id','titleAnn','dateOpen','dateClose' FROM annoucement";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query))
{
$id = $row['id'];
$title = $row['titleAnn'];
$dateOpen = $row['dateOpen'];
$dateClose = $row['dateClose'];
echo '<tr>
<td><?php echo $title ?></td>
<td><?php echo $dateOpen ?></td>
<td><?php echo $dateClose ?></td>
<td><a href="editAnnouncement.php?id=<?php echo $id;?>"><input type="button" name = "editAnn" value = "Edit" /></a></td>
<td><a href="deleteAnn.php?id=<?php echo $id;?>" onclick="confirm("Delete this announcement?");"><input type="button" name = "deleteAnn" value = "Delete"/></td>
</tr>';
}
$this->numrows= mysql_num_rows($query);
}
按钮旁边只显示空格
答案 0 :(得分:6)
你在回声中回应PHP ....如此连接和回声:
public function viewAll()
{
$sql = "SELECT 'id','titleAnn','dateOpen','dateClose' FROM annoucement";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query))
{
$id = $row['id'];
$title = $row['titleAnn'];
$dateOpen = $row['dateOpen'];
$dateClose = $row['dateClose'];
echo '<tr>
<td>'.$title.'</td>
<td>'.$dateOpen.'</td>
<td>'.$dateClose.'</td>
<td><a href="editAnnouncement.php?id='.$id.'"><input type="button" name = "editAnn" value = "Edit" /></a></td>
<td><a href="deleteAnn.php?id='.$id.'" onclick="confirm("Delete this announcement?");"><input type="button" name = "deleteAnn" value = "Delete"/></td>
</tr>';
}
$this->numrows= mysql_num_rows($query);
}
答案 1 :(得分:3)
public function viewAll()
{
$sql = "SELECT 'id','titleAnn','dateOpen','dateClose' FROM annoucement";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query))
{
$id = $row['id'];
$title = $row['titleAnn'];
$dateOpen = $row['dateOpen'];
$dateClose = $row['dateClose'];
echo '<tr>
<td>'. $title .'</td>
<td>'. $dateOpen .'</td>
<td><'. $dateClose .'</td>
<td><a href="editAnnouncement.php?id='. $id.'"><input type="button" name = "editAnn" value = "Edit" /></a></td>
<td><a href="deleteAnn.php?id='. $id.'>" onclick="confirm("Delete this announcement?");"><input type="button" name = "deleteAnn" value = "Delete"/></td>
</tr>';
}
$this->numrows= mysql_num_rows($query);
}