【发布时间】:2017-10-19 15:55:22
【问题描述】:
我们想要显示来自数据库‘X’中一个表的列表链接。 这是我的代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>database connections</title>
</head>
<body>
<?php
$username = "root";
$password = "mysql";
$host = "localhost";
$connector = mysql_connect($host,$username,$password)
or die("Unable to connect");
echo "Connections are made successfully::";
$selected = mysql_select_db("nentholbenin", $connector)
or die("Unable to connect");
//execute the SQL query and return records
$result = mysql_query("SELECT * FROM utilisateurs ");
?>
<table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;" >
<thead>
<tr>
<th>Categories</th>
</tr>
</thead>
<tbody>
<?php
$db_result = mysql_query("SELECT Categories FROM utilisateurs");
$result = $db_result; echo '<ul>';
foreach($array as $index => $db_result){
echo '<li><a href=".'$db_result['Categories'].'"</a></li>';
}
echo '</ul>';
?>
</tbody>
</table>
<?php mysql_close($connector); ?>
</body>
</html>
我收到此错误:
解析错误:语法错误,意外的“$db_result”(T_VARIABLE), 期待 ',' 或 ';'在
【问题讨论】:
-
点应该在:'.$db_result['Categories'].'
标签: html mysql hyperlink html-table