do { $result3 = mysql_query("",$db); $b = mysql_fetch_array($result3); echo "<th>".$a['dateof']."</th>"; echo "</tr><tr>"; echo "<td>".$b['mark']."</td>"; } while(); <table> <tbody> <tr> <th rowspan="2">predmet </th> <th>2016-05-19</th> </tr> <tr> <td>5</td> <th>2016-05-20</th> </tr> <tr> <td>4</td> </tr> </tbody> </table> 

I can not understand how to make a table like this in a loop:

 <table> <tr> <th rowspan="2">predm</th> <th>20.05.16</th> <th>21.05.16</th> </tr> <tr> <td>5</td> <td>4</td> </tr> </table> 

Here is a rough code of what you need:

 echo "<table><tr>"; $query = "SELECT * FROM Lessons WHERE subjectId='$subj' AND kyrs='$kyrs' AND semester='$semestr' AND groupid='$user[groupn]'"; $result2 = mysql_query($query, $db); echo "<th rowspan='2'>".$Subject['Name']."</th>"; if(mysql_num_rows($result2) > 0) { $a = mysql_fetch_array($result2); do { echo "<th>".$a['dateof']."</th>"; } while($a = mysql_fetch_array($result2)); echo "</tr><tr>"; $query = "SELECT * FROM Lessons WHERE subjectId='$subj' AND kyrs='$kyrs' AND semester='$semestr' AND groupid='$user[groupn]'"; $result2 = mysql_query($query, $db); $a = mysql_fetch_array($result2); do { $result3 = mysql_query("SELECT * FROM Marks WHERE lessonid='$a[id]' AND studentid='$_SESSION[id]'",$db); $b = mysql_fetch_array($result3); echo "<td>".$b['mark']."</td>"; } while($a = mysql_fetch_array($result2)); } else { echo "нет инфы по предмету."; } echo "</tr></table>"; 
  • It is not entirely clear, but why should I display the tablet in a cycle? usually news or images, and a sign for what? - user33274
  • I have a table on the lesson of its date and a mark on that date - Ivan Mikoryak
  • one
    absolutely monstrous use of PHP, are you being taught somewhere or are you yourself using articles and books? - strangeqargo
  • self-taught and more specifically what is wrong - Ivan Mikoryak
  • mysql driver removed, wake up. 2016 year. - Adobe

0