我正在尝试制作一个类似于页面的电子表格 - 现在我已经显示了数据库中显示的信息以及一个允许用户添加信息的附加页面。
我无法理解如何调用数据库来显示设置行。我没有运行AI id,所以这不是问题所在。我试图实现一个,但它导致我的代码不工作,并给我一个空白的白页。
以下是我用来显示数据库的代码:
<?php
$link = mysql_connect('', '', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//connect to the database
mysql_select_db('');
//query the database
$query = mysql_query("SELECT * FROM ");
echo "<table border='1'>
<tr>
<td class='td'>Date</td>
<td class='td'>Region</td>
<td class='td'>Cameraman</td>
<td class='td'>Livestream?</td>
<td class='td'>Event Title</td>
<td class='td'>Lecturer</td>
<td class='td'>Time</td>
<td class='td'>Speaker</td>
<td class='td'>ICE Contact</td>
<td class='td'>Venue Address</td>
<td class='td'>Venue Contact</td>
<td class='td'>Additional Comments</td>
<td class='td'>On App?</td>
<td class='td'>Edit</td>
<td class='td'>Delete</td>
</tr>";
WHILE($rows = mysql_fetch_array($query)):
$rows = array_filter($rows);
if (!empty($rows)) {
echo "<tr>";
echo "<td>" . $rows['date'] . "</td>";
echo "<td>" . $rows['region'] . "</td>";
echo "<td>" . $rows['cameraman'] . "</td>";
echo "<td>" . $rows['livestream'] . "</td>";
echo "<td>" . $rows['eventitle'] . "</td>";
echo "<td>" . $rows['lecturer'] . "</td>";
echo "<td>" . $rows['time'] . "</td>";
echo "<td>" . $rows['speaker'] . "</td>";
echo "<td>" . $rows['icecontact'] . "</td>";
echo "<td>" . $rows['venueaddress'] . "</td>";
echo "<td>" . $rows['venuecontact'] . "</td>";
echo "<td>" . $rows['additionalcomments'] . "</td>";
echo "<td>" . $rows['onapp'] . "</td>";
echo "<td><a href=""><img src=""></a></td>";
echo "<td><a href=""><img src=""></a></td>";
echo "</tr>";
}
endwhile;
echo "</table>";
?>
任何帮助将不胜感激。 感谢
答案 0 :(得分:0)
在if块中的第三个最后一行和倒数第二行中引用了不匹配,其中您在双引号中使用了双引号,这导致语法错误。这里的外部双引号用单引号替换。像这样更新if块:
if (!empty($rows)) {
echo "<tr>";
echo "<td>" . $rows['date'] . "</td>";
echo "<td>" . $rows['region'] . "</td>";
echo "<td>" . $rows['cameraman'] . "</td>";
echo "<td>" . $rows['livestream'] . "</td>";
echo "<td>" . $rows['eventitle'] . "</td>";
echo "<td>" . $rows['lecturer'] . "</td>";
echo "<td>" . $rows['time'] . "</td>";
echo "<td>" . $rows['speaker'] . "</td>";
echo "<td>" . $rows['icecontact'] . "</td>";
echo "<td>" . $rows['venueaddress'] . "</td>";
echo "<td>" . $rows['venuecontact'] . "</td>";
echo "<td>" . $rows['additionalcomments'] . "</td>";
echo "<td>" . $rows['onapp'] . "</td>";
echo '<td><a href=""><img src=""></a></td>';
echo '<td><a href=""><img src=""></a></td>';
echo "</tr>";
}