0

I created two tables

1. Table name: "grades"

  • id
  • subjecttype
  • grade

2. Table name: "subjects"

  • id
  • name
  • subjecttype

So in next i created table with while loop:

$sqltest1 = "SELECT * FROM grades, subjects WHERE grades.subjecttype = subject.subjectstype";
<table class="table table-bordered">
  <thead>
    <tr>
      <th class="col-1">#</th>
      <th class="col-3 text-center">Subject</th>
      <th class="col-6 text-center">Grade</th>
      <th class="col-1 text-center">Options</th>
    </tr>
  </thead>
  <tbody>
<!-- ###################################################################### -->
  <?php
  $result = $conn->query($sqltest1);
  if ($result->num_rows > 0) {
 
    // output data of each row
    while($row = $result->fetch_assoc()) {
      //$id = $row['id'];

      echo "<tr>";
      echo "<td scope='row'>1</td>";
      echo "<td>". $row['name']; "</td>";
      echo "<td>". $row["grade"]."</td>";
      echo "<td class='text-center'>Option</td>";
      echo "</tr>";
  }


} else {
echo "";
}

?>

<!-- ###################################################################### -->
</tbody>
</table>

My problem is - i want to display all of grades for specify subjecttype in one but actually i've got something like this:

enter image description here

and I would like to get something like this (image 2) - what am doing wrong?

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135

0 Answers0