2016-09-14 17 views
-1

爲了獲得同一個表中的所有科目,我需要從下面的代碼更改什麼?我的表單中的所有科目都在同一張表中

<?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> 
+0

Uhmm ......什麼?我不太瞭解你的問題。 –

+0

我有不同表格中的每個主題 –

+0

您需要向我們展示'$ mysubject'的結構。我們甚至無法開始幫助您提供的有限信息。 – nerdlyist

回答

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> 
相關問題