为了让所有主题都在同一个表格中,我需要从下面的代码中进行哪些更改?
<?php
include('grade.php');
$mysubject = $grade->getsubject();
?>
<p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<?php foreach($mysubject as $row): ?>
<div class="col-lg-4 gradeform">
<div class="form_hover " style="background-color: #428BCA;">
<p style="text-align: center; margin-top: 20px;">
<i class="fa fa-bar-chart-o" style="font-size: 147px;color:#fff;"></i>
</p>
<div class="header">
<div class="blur"></div>
<div class="header-text">
<div class="panel panel-success" style="height: 247px;">
<div class="panel-heading">
<h3 style="color: #428BCA;">Subject: <?php echo $row['subject'];?></h3>
</div>
<div class="panel-body">
<table class="table table-bordered">
<tr class="alert alert-danger">
<th>TD</th>
<th>Exam</th>
<th>catching</th>
<th>average</th>
</tr>
<?php $mygrade = $grade- >getgrade($row['id']); ?>
<tr>
<td><?php echo $mygrade['att1']; ?></td>
<td><?php echo $mygrade['exam1']; ?></td>
<td><?php echo $mygrade['quiz1']; ?></td>
<td><?php echo $mygrade['project1']; ?></td>
</tr>
</table>
<div class="form-group">
<?php $teacher = $grade->getteacher($row['id']); ?>
<label>Teacher: <?php echo $teacher;?></label><br />
<label>Semester: <?php echo $row['sem']?> Sem</label><br />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
答案 0 :(得分:0)
我的每个主题都在不同的表格中
问题是,在foreach
循环的每次迭代中,您都在创建一个新表。如果您想在一个表格下显示所有主题,只需在<table>
循环外部foreach
,如下所示:
// your code
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-lg-4 gradeform">
<div class="form_hover " style="background-color: #428BCA;">
<p style="text-align: center; margin-top: 20px;">
<i class="fa fa-bar-chart-o" style="font-size: 147px;color:#fff;"></i>
</p>
<div class="header">
<div class="blur"></div>
<div class="header-text">
<div class="panel panel-success" style="height: 247px;">
<table class="table table-bordered">
<?php foreach($mysubject as $row): ?>
<div class="panel-heading">
<h3 style="color: #428BCA;">Subject: <?php echo $row['subject'];?></h3>
</div>
<div class="panel-body">
<tr class="alert alert-danger">
<th>TD</th>
<th>Exam</th>
<th>catching</th>
<th>average</th>
</tr>
<?php $mygrade = $grade- >getgrade($row['id']); ?>
<tr>
<td><?php echo $mygrade['att1']; ?></td>
<td><?php echo $mygrade['exam1']; ?></td>
<td><?php echo $mygrade['quiz1']; ?></td>
<td><?php echo $mygrade['project1']; ?></td>
</tr>
<div class="form-group">
<?php $teacher = $grade->getteacher($row['id']); ?>
<label>Teacher: <?php echo $teacher;?></label><br />
<label>Semester: <?php echo $row['sem']?> Sem</label><br />
</div>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>