springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2022-10-19 13:10:56
129
我使用的是Laravel 8框架。
使用查询从表中获取值并在复选框中显示,但是当我选择多个值时,它只显示单个值,而不显示多个值。
这是带有查询的刀片PHP代码。
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Students:</strong>
<div style="margin-top: 5px" >
<?php $conn = new mysqli('localhost', 'root', '', 'rp') or die ('Cannot connect to db');
$result = $conn->query("select users.id, users.name from users, model_has_roles where model_has_roles.model_id=users.id and model_has_roles.role_id=14;
");
echo "<html>";
echo "<body>";
while ($row = $result->fetch_assoc()) {
unset($id, $name);
$id = $row['id'];
$name = $row['name'];
echo '<form><input type=checkbox name="student_id[]" value="'.$id.'">'.$name.'</form>'; }
//echo "</select>";
echo "</body>";
echo "</html>";?>
他是我在控制器中的函数代码
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Students:</strong>
<div style="margin-top: 5px" >
<?php $conn = new mysqli('localhost', 'root', '', 'rp') or die ('Cannot connect to db');
$result = $conn->query("select users.id, users.name from users, model_has_roles where model_has_roles.model_id=users.id and model_has_roles.role_id=14;
");
echo "<html>";
echo "<body>";
while ($row = $result->fetch_assoc()) {
unset($id, $name);
$id = $row['id'];
$name = $row['name'];
echo '<form><input type=checkbox name="student_id[]" value="'.$id.'">'.$name.'</form>'; }
//echo "</select>";
echo "</body>";
echo "</html>";?>
正如您所看到的,如果我把它作为一个注释,它永远不会转到
中的前一个注释如何从复选框中获取多个值?
顺晟科技:
dd();终止循环并只返回应该回显结果的第一个值,而不是dd();它们或使用。
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Students:</strong>
<div style="margin-top: 5px" >
<?php $conn = new mysqli('localhost', 'root', '', 'rp') or die ('Cannot connect to db');
$result = $conn->query("select users.id, users.name from users, model_has_roles where model_has_roles.model_id=users.id and model_has_roles.role_id=14;
");
echo "<html>";
echo "<body>";
while ($row = $result->fetch_assoc()) {
unset($id, $name);
$id = $row['id'];
$name = $row['name'];
echo '<form><input type=checkbox name="student_id[]" value="'.$id.'">'.$name.'</form>'; }
//echo "</select>";
echo "</body>";
echo "</html>";?>
既然我不知道你想做什么,我就放弃第二个想法
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Students:</strong>
<div style="margin-top: 5px" >
<?php $conn = new mysqli('localhost', 'root', '', 'rp') or die ('Cannot connect to db');
$result = $conn->query("select users.id, users.name from users, model_has_roles where model_has_roles.model_id=users.id and model_has_roles.role_id=14;
");
echo "<html>";
echo "<body>";
while ($row = $result->fetch_assoc()) {
unset($id, $name);
$id = $row['id'];
$name = $row['name'];
echo '<form><input type=checkbox name="student_id[]" value="'.$id.'">'.$name.'</form>'; }
//echo "</select>";
echo "</body>";
echo "</html>";?>
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11