belhadj abdou belhadj abdou - 2 months ago 8
PHP Question

all subjects in same table in my sheetmark

What do I need to change from below code in order to get all the subjects in the same table?

<?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 &raquo;</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>

Answer

i have every subject in différent table

The problem is, in each iteration of foreach loop you're creating a new table. If you want to display all the subjects under one table, just take the <table> outside of your foreach loop, like this:

// 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>
Comments