我正在尝试填充一个从MySQL检索数据库的下拉框。下面是我的表单和php文件。对我来说它看起来不错,但我不明白为什么当我点击提交按钮时它没有显示任何东西。我能做些什么来解决这个错误吗?任何更正和建议将不胜感激。
CS_JOBS
表包括:job_title
, category_code
(17, 27, 37....), ...等。
connect.php在这种情况下工作正常。
我的表格
<!DOCTYPE html>
<html>
<head></head>
<body>
<form action = "csjob.php" method = "POST" name = "jobsearch">
<select name = "category_code[]">
<option value = "17">Architecture and Engineering</option>
<option value = "27">Arts, Design, Entertainment, Sports, and Media</option>
<option value = "37">Building and Grounds Cleaning and Maintenance</option>
<option value = "13">Business and Financial Operations</option>
<option value = "21">Community and Social Services</option>
<option value = "15">Computer and Mathematical</option>
<option value = "47">Construction and Extraction</option>
<option value = "25">Education, Training, and Library</option>
<option value = "45">Farming, Fishing, and Forestry</option>
<option value = "35">Food Preparation and Serving Related</option>
<option value = "29">Healthcare Practitioner and Technical</option>
<option value = "31">Healthcare support</option>
<option value = "49">Installation, Maintenance, and Repair</option>
<option value = "23">Legal</option>
<option value = "19">Life, Physical, and Social Science</option>
<option value = "11">Management</option>
<option value = "43">Office and Administrative Support</option>
<option value = "39">Personal Care and Service</option>
<option value = "51">Production</option>
<option value = "33">Protective Service</option>
<option value = "41">Sales and Related</option>
<option value = "53">Transportation and Material Moving</option>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>
csjob.php
<?php
require("connect.php");
if(isset($_POST['submit'])){
$sql = "SELECT * FROM CS_JOBS WHERE category_code=".$_POST['category_code'];
$result = mysql_query($sql);
echo "<select name='category_code'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='".$row['job_title']"'>".$row['job_title']"</option>";
}
echo "</select>";
}
?>
这个问题有很多错别字,这是我上传的实际代码:链接!