Hi guys, I am working on my tv guide website that I output the data to my php from mysql database. I want to know how i can work it out the tv time for per programme how long they would last for, e.g 30 mins, 1 hour...etc <html> <body> <style type="text/css"> #channel1 { position:absolute; font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; visibility:visible; overflow:hidden; left:35px; top:245px; width:176px; height:50px; z-index:1; } #programme1 { position:absolute; font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; visibility:visible; overflow:hidden; left:427px; top:245px; width:176px; height:50px; z-index:1; } #programme2 { position:absolute; font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; visibility:visible; overflow:hidden; left:765px; top:245px; width:176px; height:50px; z-index:1; } #programme3 { position:absolute; font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; visibility:visible; overflow:hidden; left:1110px; top:245px; width:176px; height:50px; z-index:1; } #day { font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; position:absolute; visibility:visible; overflow:hidden; left:294px; top:180px; width:176px; height:50px; z-index:0; } #time1 { font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; position:absolute; visibility:visible; overflow:hidden; left:424px; top:180px; width:176px; height:50px; z-index:0; } #time2 { font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; position:absolute; visibility:visible; overflow:hidden; left:754px; top:180px; width:176px; height:50px; z-index:0; } #time3 { font-family:Arial; font-size:29px; font-style:normal; font-weight:bold; color:f5fdfd; text-decoration:none; text-transform:none; position:absolute; visibility:visible; overflow:hidden; left:1104px; top:180px; width:176px; height:50px; z-index:0; } <?php include("get-listing.php"); ?> <div id="image1" style="position:absolute; overflow:hidden; visibility:visible; left:21px; top:245px; width:374px; height:40px; z-index:0"><img src="/images/row1_yellow.jpg" alt="" title="" border=0 width=374 height=50></div> <div id="image2" style="position:absolute; overflow:hidden; visibility:visible; left:21px; top:295px; width:374px; height:40px; z-index:0"><img src="/images/row1.jpg" alt="" title="" border=0 width=374 height=50></div> <div id="image3" style="position:absolute; overflow:hidden; visibility:visible; left:21px; top:345px; width:374px; height:40px; z-index:0"><img src="/images/row1.jpg" alt="" title="" border=0 width=374 height=50></div> </body> </html> PHP: get-listing.php <html> <body> <script> function ajaxpage(str) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP") } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { } } xmlhttp.open("GET",".php?q="+str,true); xmlhttp.send(); } </script> <?php define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydbname_tvguide'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qrytable1="SELECT id, channels FROM tvguide"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo "</br>"; echo "<td>".$row['channels']."</td>"; echo "</br>"; } } mysql_close($link); ?> </body> </html> PHP: I am using the row1 as per image to resize it for per programme, but i have no idea how i can compare with each timing for per programme before resizing on per image. here is what my php displaying: <span id='time1'>1:00 PM</span> - <span id='title1'>SportsCenter</span><br></br><span id='time2'>2:00 PM</span> - <span id='title2'>SportsCenter</span><br></br><span id='time3'>3:00 PM</span> - <span id='title3'>SportsCenter Special: On the Clock</span><br></br><span id='time4'>4:00 PM</span> - <span id='title4'>NFL Live</span><br></br> Code (markup): I want to know how to work it out on per timing how long the programme will last for, e.g I want to work it out between time1 and time2 to find out how long it will last which it make 60 mins. Does anyone know how i can compare with each timing on per programme before resizing on per image? Any advice would be much appreicated. Thanks in advance
If I'm understanding correctly, i'd do something like this: Using jQuery, I'd select the text from each element. jQuery('#time1').text(); You can use the .split command then to separate the space from "2:00" and "PM", then again, use .split on the ":" to get the integer. I'd post that to my method to then manipulate in PHP. You can use PHP subtraction functionality to get the difference and echo to the browser (within a loop).