我自告奋勇,想创造一些还挺数据库供我上学,有效地跟踪学生的不当行为。我不是专家。我一直在做的是,我为了我想要的,自学了它,并试图将所有东西缝合在一起。PHP动态复选框列表,基于级联选择选择
我碰到这个教程,差不多就是我想要的,我的工作在此基础上对数据库:http://www.yourinspirationweb.com/en/how-to-create-chained-select-with-php-and-jquery/
,因此,我想出了这一点:http://ipoh.wesleyschool.edu.my/ace_beta.php
整体思路是基于选择的班级,该特定班级的学生将作为列表出现。
整个事情的作品的那一刻,但我想它推到另一个层次。正如你所看到的,我写的东西只允许一个学生一次,如果我想同时选择多个学生做同样的错误行为呢?
我Google的“动态复选框”等。但不知何故,我不知道将它们连接,使其工作...我已经试了又试,这就是为什么你在这里找到我问。
CODE(ace_beta.php):
主网页上运行:ace_beta.php;其中,我相信我卡在这个地方:
<td width="25%" valign="top"'>
<table border="0" width="100%" cellpadding="6">
<tr>
<td width="100%" align="middle" valign="top" bgcolor='#636363'>
<font face="Arial" size='5' color='#ffffff'><b> STEP ONE </b></font>
</td></tr></table>
<br />
<b> STUDENT INFORMATION ::. </b>
<br />
<table border="0" width="100%" cellpadding="3">
<tr>
<td width="20%" align="right"> class </td>
<td width="80%" align="left">
<select id="class" name="class">
<?php echo $opt->ShowClass(); ?>
</select></td>
</tr>
<tr>
<td width="20%" align="right"> student </td>
<td width="80%" align="left">
<select id="student" name="student">
<option value="0">choose...</option>
</select></td>
</tr>
</table>
</td>
ace_beta.php是紧密相连的select.class.php其中函数存储...
CODE(select.class。 PHP)
<?php
class SelectList
{
protected $conn;
public function __construct()
{
$this->DbConnect();
}
protected function DbConnect()
{
include "db_config.php";
$this->conn = mysql_connect($host,$user,$password) OR die("Unable to connect to the database");
mysql_select_db($db,$this->conn) OR die("can not select the database $db");
return TRUE;
}
public function ShowClass()
{
$sql = "SELECT * FROM class";
$res = mysql_query($sql,$this->conn);
$class = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$class .= '<option value="' . $row['id_cls'] . '">' . $row['name'] . '</option>';
}
return $class;
}
public function ShowStudent()
{
$sql = "SELECT * FROM student WHERE id_cls=$_POST[id]";
$res = mysql_query($sql,$this->conn);
$student = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$student .= '<option value="' . $row['id_stu'] . '">' . $row['name'] . '</option>';
}
return $student;
}
}
$opt = new SelectList();
?>
问题
可有人是一种足以指导我虽然豪w至做到以下几点:
- 基于“选课”的ace_beta.php,复选框 承载相应的同学会出现在ace_beta.php
- 中的“学生 区”名单方法来处理所选名称,在 之后的ace_add.php中点击“提交”按钮。
我想帮助你,这是一个非常深思熟虑的问题,我很欣赏提出的时间和精力。只是一些澄清问题。你想显示一个'>'而不是'
非常感谢您的回复!理想情况下,我希望它会显示一个复选框列表(早先你建议)与学生的名字从数据库中绘制...谢谢,祝你圣诞节=) – Abel
这样的事情http://checkboxtree.googlecode.com /svn/tags/checkboxtree-0.5.2/index.html?如果是的话,看看这个惊人的项目:http://code.google.com/p/checkboxtree/ – sdespont