My tables:
timetable
+----+---------+-------+--------+---------+---------+------+
| id | user_id | s_day | s_hour | subject | teacher | room |
+----+---------+-------+--------+---------+---------+------+
| 1 | 1 | 1 | 1 | MATH | SM | 101 |
| 2 | 1 | 1 | 2 | MATH | SM | 101 |
| 3 | 1 | 1 | 3 | MATH | SM | 101 |
| 4 | 1 | 1 | 4 | MATH | SM | 101 |
| 5 | 1 | 1 | 5 | MATH | SM | 101 |
| 6 | 1 | 1 | 6 | MATH | SM | 101 |
| 7 | 1 | 2 | 1 | MATH | SM | 101 |
| 8 | 1 | 2 | 2 | MATH | SM | 101 |
| .. | ... | ... | ... | ... | ... | ... |
users
+---------+----------+----
| user_id | username | ...
+---------+----------+----
| 1 | User1 | ...
+---------+----------+----
Now I want to output this timetable into a html-table with inputfields.
HTML table
<tr> //this would be the row for the first hour
<td align="middle" class="td_contentbar" style="white-space:nowrap">1</td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_1_1"><input class="inputfeld sp_input" id="teacher_1_1"><input class="inputfeld sp_input" id="room_1_1"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_2_1"><input class="inputfeld sp_input" id="teacher_2_1"><input class="inputfeld sp_input" id="room_2_1"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_3_1"><input class="inputfeld sp_input" id="teacher_3_1"><input class="inputfeld sp_input" id="room_3_1"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_4_1"><input class="inputfeld sp_input" id="teacher_4_1"><input class="inputfeld sp_input" id="room_4_1"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_5_1"><input class="inputfeld sp_input" id="teacher_5_1"><input class="inputfeld sp_input" id="room_5_1"></td>
</tr>
<tr> //this would be the row for the 2nd hour
<td align="middle" class="td_contentbar" style="white-space:nowrap">2</td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_1_2"><input class="inputfeld sp_input" id="teacher_1_2"><input class="inputfeld sp_input" id="room_1_2"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_2_2"><input class="inputfeld sp_input" id="teacher_2_2"><input class="inputfeld sp_input" id="room_2_2"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_3_2"><input class="inputfeld sp_input" id="teacher_3_2"><input class="inputfeld sp_input" id="room_3_2"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_4_2"><input class="inputfeld sp_input" id="teacher_4_2"><input class="inputfeld sp_input" id="room_4_2"></td>
<td align="middle" class="td_contentbar"><input class="inputfeld sp_input" id="subject_5_2"><input class="inputfeld sp_input" id="teacher_5_2"><input class="inputfeld sp_input" id="room_5_2"></td>
</tr>
syntax for the id's of the input's:
subject_5_2
subject/teacher/room _ day (5 -> friday) _ hour (2 -> 2nd)
I thought about putting the complete mysql result in a multidimensional array like this:
$timetable[day][hour]
But how can I do this or is this method stupid? Or should I redesign the system completly?

SELECT s_day, s_hour, subject, teacher, room FROM timetable WHERE user_id = ?(I use prepared statements, so the ? will be the id of the logged in user