<?php
$host = 'localhost';
$user = 'root';
$pass = '******';
$db = 'test';
$error = 'Error Connecting to database';
$error1 = 'Error Selecting to database';
$connect = mysql_connect($host,$user,$pass) or die($error);
$select_db = mysql_select_db($db) or die($error1);
?>
<table border="1px">
<tr>
<div class="differentLine">
<th > </th>
<th > 9:15 - 10:15 </th>
<th > 10:15 - 11:15 </th>
<th > 11:15 - 12:15 </th>
<th > 12:15 - 13:15 </th>
<th > 13:15 - 14:15 </th>
<th > 14:15 - 15:15 </th>
<th > 15:15 - 16:15 </th>
<th > 16:15 - 17:15 </th>
<th > 17:15 - 18:15 </th>
</div>
</tr >
<tr>
<th >Monday </th>
<?php
$sqlip = "Select * From Modules";
$query = mysql_query($sqlip) or die("Error");
while($row = mysql_fetch_array($query))
{
$name = $row['Name'];
$day = $row['Day'];
$start_time = $row['Start_Time'];
$End_Time = $row['End_Time'];
echo "
<td> $name</td>";
}
?>
I'm making a simple PHP timetabling website. I've made a table and I have the times in a horizontal header and days Monday to Friday in a vertical header. I'm just unsure of how to put the correct data in the correct times.
My database has id, name, startTime, endTime and Day
Some data could be 0, Basketball, 9:00, 10:00, Mon.
I currently have a while loop that can fill in the table, but not in the correct slots (td).
Here is my table code so far: