我正在做作业。我只需要在选中复选框时使用jquery显示按钮,并且只针对少数主题。所有主题都来自使用php和mysql的后端。表正在动态获取主题。
我想显示按钮或文本时,只有少数科目被选中
这是密码
<?php
if($stmt = $conn->prepare("SELECT classid, code, name, teacher, classroom,
time, cost FROM classes ORDER BY classid")){
// $stmt->bind_param("isssssd");
$result = $stmt->execute();
$stmt->bind_result($classid, $code, $name, $teacher, $classroom, $time,
$cost);
$checked = "";
while ($stmt->fetch()) {
$row = array("classid"=>$classid, "code"=>$code, "name"=>$name,
"teacher"=>$teacher, "classroom"=>$classroom, "time"=>$time, "cost"=>$cost);
if(in_array($classid, $selectedclasses)){
$checked = "checked";
}else{
$checked = "";
}
?>
<div class="row col-md-12">
<hr/>
</div>
<div class="row col-md-12" id="class_<?php echo $classid; ?>">
<div class="col-md-4 col-lg-4 col-sm-6 col-sx-6">
<input type="checkbox" id="classitem_<?php echo $classid; ?>"
name="classitem_<?php echo $classid; ?>" class="classitem" value="<?php echo
$classid; ?>" <?php echo $checked; ?> > <?php echo $name; ?>
</div>
<div class="col-md-2 col-lg-2 col-sm-6 col-sx-6">
<?php echo $teacher; ?>
</div>
<div class="col-md-2 col-lg-2 col-sm-6 col-sx-6">
<?php echo $cost; ?>
</div>
<div id="mine" class="col-md-4 col-lg-4 col-sm-6 col-sx-6">
<?php echo $time; ?>
</div>
</div>
<?php
}
$stmt->close();
}
?>
1条答案
按热度按时间nbysray51#
你需要尝试下面给出的方法。