need your help again.
So I have a query, with multiple variables which I have to output to a table.
Here is the query:
SELECT DISTINCT
zi.zile,
ore.ora AS ore,
materii.materie
FROM
zi LEFT JOIN orar ON zi.id = orar.id_zi
LEFT JOIN ore ON ore.id = orar.id_ora
LEFT JOIN nume_scoli ON nume_scoli.id = orar.id_scoala
LEFT JOIN materii_pe_clase ON materii_pe_clase.id_scoala = nume_scoli.id
LEFT JOIN clase ON materii_pe_clase.id_clasa = clase.id AND orar.id_clasa = clase.id
LEFT JOIN elevi ON elevi.id_clasa = materii_pe_clase.id_clasa
LEFT JOIN materii ON materii.id = orar.id_materie
WHERE clase.`id`=1
ORDER BY zi.`zile`, ore.`id` ASC
and the result of this query looks like this :
Now this is what I`ve done in php:
$oraru = "the query from up this page ";
$gaseste_oraru = mysql_query($oraru);
$numar_orar = mysql_num_rows($oraru);
if($numar_orar==0)
{
echo "Orarul nu este disponibil momentan.";
}
else
{
while($randorar=mysql_fetch_array($gaseste_oraru))
{
$ziorar = $randorar['zile'];
$oraorar = $randorar['ore'];
$materieorar = $randorar['materie'];
}
}
This is the table I want to populate with data from the database:
Here you have the code of the table:
<div class="CSSTableGenerator" >
<table >
<tr>
<td>
Orar
</td>
<td>
Luni
</td>
<td >
Marti
</td>
<td>
Miercuri
</td>
<td>
Joi
</td>
<td>
Vineri
</td>
</tr>
<tr>
<td >
8:00 - 9:00
</td>
<td>
<select>
<option>Mate</option>
<option>Romana</option>
<option>Geogra</option>
</select>
</td>
<td>
<select>
<option>Mate</option>
<option>Romana</option>
<option>Geogra</option>
</select>
</td>
<td>
<select>
<option>Mate</option>
<option>Romana</option>
<option>Geogra</option>
</select>
</td>
<td>
<select>
<option>Mate</option>
<option>Romana</option>
<option>Geogra</option>
</select>
</td>
<td>
rand 1
</td>
</tr>
<tr>
<td >
9:00 - 10:00
</td>
<td>
rand 2
</td>
<td>
rand 2
</td>
<td>
rand 1
</td>
<td>
rand 1
</td>
<td>
rand 1
</td>
</tr>
<tr>
<td >
10:00 - 11:00
</td>
<td>
rand 2
</td>
<td>
rand 2
</td>
<td>
rand 1
</td>
<td>
rand 1
</td>
<td>
rand 1
</td>
</tr>
<tr>
<td >
11:00 - 12:00
</td>
<td>
rand 3
</td>
<td>
rand 3
</td>
<td>
rand 1
</td>
<td>
rand 1
</td>
<td>
rand 1
</td>
</table>
</div>
NEVERMIND THE DROPDOWNS, I WON`T USE THEM!
Do you have any idea how to populate it, BUT if nothing exists for an interval (e.g Luni 8:00-9:00), then write nothing in the table?
EDIT
Here is what I tried :
<div class="CSSTableGenerator" >
<table >
<tr>
<td>
Orar
</td>
<?php
{
$oraru = "the query from up this page";
$gaseste_oraru = mysql_query($oraru);
while($randorar=mysql_fetch_array($gaseste_oraru))
{
$ziorar = $randorar['zile'];
$oraorar = $randorar['ore'];
$materieorar = $randorar['materie'];
echo "<td>";
echo $randorar['zile'];
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo $randorar['ore'];
echo "</td>";
echo"<td>";
echo $randorar['materie'];
echo "</td>";
echo "</tr>";
}//sfarsit while
Here is the result:
Any ideas?