Radio schedule php -


i making radio scheduler. should show program on now.

<?php header('access-control-allow-origin: *'); ?> <?php mysql_connect("localhost", "dennis", "***") or die(mysql_error()); mysql_select_db("daletnew") or die(mysql_error()); date_default_timezone_set('europe/amsterdam'); $day = date('l'); $hour = date('h');   $query = "select time_end shows day='$day' , time_start='$hour'"; $result = mysql_query($query);  $query = "select * shows day='$day' , time_start='$hour'"; $result = mysql_query($query); if (mysql_num_rows($result)==0) {   echo '<div id="onair_info" style="position: relative; top: 40px;">'; echo '<br />'; echo '<div class="info_time_time" style="position: relative; left: 4px; color: #2980b9; font-size: 18px; font-family: roboto; font-weight:300; top: -10px; ">'; echo "favoritefm music"; echo '</div>'; echo '</div>';  } else {  while ($row = mysql_fetch_assoc($result)) {      $show_name = $row['show_name'];      $dj = $row['dj'];       $time_start = $row['time_start'];       $time_stop = $row['time_stop'];        $sql1 = "select * dj dj='$dj'"; $result1 = mysql_query($sql1);  while($info1 = mysql_fetch_array($result1))   {  $image_url = $info1['image_url']; }  echo '<div id="circle" style="position: relative; top: 40px; left: 175px; width:50px;height:50px; border-color:#00aeff; border-radius:50px; line-height:100px;text-align:center; background-repeat: no-repeat; background-image: url(' . $image_url . ');"></div>';       echo '<div id="onair_info" style="position: relative; top: 0px;">'; echo '<div class="info_time_live" style="position: relative; color: #2980b9; font-size: 12px; font-family: roboto;top: -12px;left: 20px;">'; echo 'live </div>'; echo '<div class="info_time_time" style="position: relative; left: 60px; color: #2980b9; font-size: 12px; font-family: roboto;top: -26px;">'; echo $time_start; echo '</div>'; echo '<div class="arrow_to_right" style="position: relative; width:15px; top: -40px;left: 80px;height:15px; background-repeat: no-repeat; background-image:url(\'http://test.favoritefm.com/wp-content/themes/favoritefm/img/arrow_to_right.png\')"></div>'; echo '<div class="info_time_time" style="position: relative; left: 100px; color: #2980b9; font-size: 12px; font-family: roboto;top: -55px;">'; echo $time_stop; echo '</div>'; echo '<br />'; echo '<div class="info_show" style="position: relative; top: -57px; left: 20px; color: #2980b9; font-size: 14px; font-family: roboto;">'; echo '<div class="dj_name" style="font-size: 15px; font-family: roboto; font-weight: bold";>'; echo $dj; echo '</div>'; echo '<br />'; echo '<div class="show_name" style="font-size: 14px; font-family: roboto;position: relative;top: -15px">'; echo $show_name; echo '</div>'; echo '</div>'; echo '</div>'; } }  ?> 

obviously, shows shows last 1 hour. have shows start @ 12 , end @ 16. don't know start or how it. how can script show radio show between 12 , 16? have beginning , end time in table als time_start , time_stop.

try changing second sql line this:

$query = "select * shows day='$day' , time_start<=$hour , time_stop>$hour"; $result = mysql_query($query); 

you can remove first sql query , keep other code same. uses sql comparison operators return radio show if current hour between start , end hours. using example (12-16 hours), 12:15 , 15:50 return show, 11:55 , 16:05 not.

edit: please ensure time_start , time_stop sql int type, , $hour int. comparison operators can't compare strings.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -