我想要一个表单,允许用户通过选中复选框来选择要从表中显示的数据。如果用户只想显示 2 列,则应该只显示 2 列。我有我的代码,但提交后,它什么也没显示。这是我的代码:
<form name="form1" method="post" action="view_emp.php">
<p>Select Option
<input type="checkbox" name="number[]" value="name" />Name
<input type="checkbox" name="number[]" value="hired" />Date Hired
<input type="checkbox" name="number[]" value="basic" />Basic Pay
<input type="checkbox" name="number[]" value="incentives">Incentives
</p>
<input type="submit" name="Submit" value="Submit">
</form>
这是我的php:
<?php
$db = mysql_connect('localhost', 'root', '');
mysql_select_db('eis', $db) or die (mysql_error());
$employee = array();
foreach ($_POST['number'] as $employee) {
$number = mysql_real_escape_string($number);
$employee[] = "'{$number}'";
}
$sql = "select * from employees where type in (" .implode(", ", $number). ")";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
print $row['name'];
}
?>
我是 php 的初学者,我需要大师和专家的帮助。谢谢你...