【发布时间】:2015-01-10 02:38:34
【问题描述】:
我一直在尝试从下拉菜单中的数据库 mysqli 中提取数据。这是我的 postad.html 代码。我想从具有行名称 CatName 的类别表中提取类别数据。我也有显示 ctegory id 的 CatId。提前谢谢你。请帮助:
<html>
<head>
<title>Post AD</title>
</head>
<body>
<form method="POST" action="postad.php">
<table>
<tr>
<td>AdName:</td>
<td><input type="text" name="adname"></td>
</tr>
<tr>
<td>AdCategory</td>
<td>
//dropdown list
<select name="Categories">
<?php include = connect.php
$sql = "SELECT CatName FROM categories order by CatName";
$result = $db->query($sql);
while($row = $result->fetch_array()) {
echo "<option value='". $row['CatName']."'>."</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>Contact Number</td>
<td><input type="text" name="contactnumber"></td>
</tr>
<tr>
<td>Image</td>
<td><input type="text" name="image"></td>
</tr>
<tr>
<td>Description</td>
<td><input type="text" name="description"></td>
</tr>
<tr>
<td>Expiration Date</td>
<td><input type="text" name="expirationdate"></td>
</tr>
<tr>
<td id="btn"><input type="submit" value='submit' name="submit"></td>
</tr>
</table>
</form>
</body>
</html>
【问题讨论】:
-
“这是我的 postad.html 代码” - 你里面有 PHP/SQL。另外,您还缺少分号
<?php include = connect.php<?php include 'connect.php'; 减去= -
很难回答这个问题...什么没有发生?数据库中有什么东西吗?那么 include = connect.php 呢?