0
我正在尝试动态创建一个HTML表格。显然,我做错了什么,但是什么?请帮忙!我该如何在PHP文件中创建HTML表格?
$foo_connection = db_connect($host, $user_name, $user_password, $database);
$sql = "SELECT id, heading FROM articles";
$result = mysqli_query($foo_connection, $sql);
if(mysqli_num_rows($result) > 0) {
print "<table>";
foreach($result as $key => $cols) {
print "<tr><td>".$cols['id']."</td>"."<td>".$cols['heading']."</td></tr>";
}
print "</table>";
}
else {
print "0 results";
}
mysqli_close($foo_connection);
输出是什么? –
@IvankaTodorova print $ cols ['id']。“”。$ cols ['heading']; –
看起来对我来说很好:http://sandbox.onlinephpfunctions.com/code/fa4b76591a84ef80905115399fbf47a575311c5a你确定你真的把它当作PHP来运行吗? –