How to move a cell in a table based on xml data?



I'm creating a tv anime guide in a table in html. I have an xml file with all the data such as name, start time, end time etc. I want the cell in the table to be placed in the right position in between the start and end times that the xml file data shows in the html table. How can I do this? The table only shows time such as 9am, 10am...but like the table below shows an episode could begin between 9.30 to 10.30. For instance, attack on titan begins at 9.30 and finishes at 10.30, and death note begins at 12pm and finishes at 1pm. I was thinking to some how do it by the id in the cell of the table but I'm clueless on how. See below for an example:


enter image description here


Here is the XML file:



<?xml version="1.0" encoding="UTF-8"?><anime_data>
<anime id="1">
<action_adventure_channel>
<name>Attach on Titan</name>
<start_time>09.30am</start_time>
<end_time>10.30am</end_time>
</action_adventure_channel>
</anime>
<anime id="2">
<crime_drama_channel>
<name>Death Note</name>
<start_time>12.00pm</start_time>
<end_time>1.00pm</end_time>
</crime_drama_channel>
</anime></anime_data>


Here is the HTML file:



<!DOCTYPE html>

<html><head><title>Anime</title>
<link rel="stylesheet" type="text/css" href="anime.css">
</head>
<body>
<table style="width:100%">
<tr>
<th class = "table-main">Channel</th>
<th class = "time" id ="9.00am">9AM</th>
<th class = "time" id ="9.30am"></th>
<th class = "time" id ="10.00am">10AM</th>
<th class = "time" id ="10.30am"></th>
<th class = "time" id ="11.00am">11AM</th>
<th class = "time" id ="11.30am"></th>
<th class = "time" id ="12.00pm">12PM</th>
<th class = "time" id ="12.30pm"></th>
<th class = "time" id ="1.00pm">1PM</th>

</tr>

<tr>
<td class = "table-main">Action/Adventure</td>
<td>
<?php
$xml=simplexml_load_file("anime.xml") or die("Error: Cannot create object");
echo $xml->anime[0]->action_adventure_channel->name;
?>


</td>
</tr>
<tr>
<td class = "table-main">Crime/Drama</td>
<td>
<?php
$xml=simplexml_load_file("anime.xml") or die("Error: Cannot create object");
echo $xml->anime[1]->crime_drama_channel->name;
?>
</td>
</tr>
</table>
</body>
</html>

No comments:

Post a Comment