我在获取数据库填充复选框的文本值时遇到了一些问题。下面是根据我的查询填充复选框的查询。
if (isset($_POST['submitCourseCode'])) {
$aElective = $_POST['electiveModules'];
foreach(array_keys($aElective) as $elec) {
echo "$elec";
}
}
echo "<form name=\"psform\" action=\"plotyourcourseGraphpSave.php\" method=\"post\">";
$moduleQuery = "SELECT module.*,group_elective_modules.moduleID
FROM module,group_elective_modules
WHERE group_elective_modules.courseName = '$courseTitle'
AND group_elective_modules.yr = '$year'
AND group_elective_modules.moduleID = module.ID ";
$moduleResult = mysql_query($moduleQuery );
while ($row = mysql_fetch_array($moduleResult)) {
echo "<input type=\"checkbox\" name=\"electiveModules[]\" value=\"{$row['title']}\" /> {$row['title']}<br />";
}
echo "<input type=\"submit\" name=\"submitCourseCode\" value=\"Submit\" />
</form>";
这是屏幕截图
选中复选框的结果
但这就是我想要的
Threshold French
French for Reading Purposes I
German Language (Beginner [00] Level)
German Language (Intermediate [05] Level)
因此,当我选择几个复选框并按下提交时,它会传递我选择的复选框的数值,但我想要文本值。请问有什么帮助吗?