if ($_GET['sort'] != '') { $sort = $_GET['sort']; } $id = ""; if ($_GET['id'] != '') { $id = $_GET['id']; } /*----- CONTENT ------*/ ?> <div class="row"> <div class="nine columns content"> <h1>On Demand</h1> <?php if ($id == "") { echo '<div class="center">Sort: [ <a href="ondemand.php?sort=date">Newest</a> | <a href="ondemand.php?sort=artist">Artist</a> | <a href="ondemand.php?sort=text">List</a> | <a href="http://www.youtube.com/ynotradio" target="_new">Videos</a> | <a href="shows.php">Specialty Shows</a> ] </div>'; show_on_demand($sort); } else { echo '<table class="ondemand">'; on_demand_player($id); echo '</table>'; echo '<a href="ondemand.php?sort=text"><< Back to list</a>'; } ?> </div> <div class="three columns"><?php require "partials/_featured_concerts_and_ads.php"; ?> </div> </div> <!-- end of row div --> <?php require "partials/_footer.php";
function show_on_demand($sort) { $tbl_name = "ondemand"; if ($sort != "text") { $adjacents = 3; $count_query = "SELECT COUNT(*) as num FROM {$tbl_name} WHERE DELETED = 'no'"; $total_pages = mysql_fetch_array(mysql_query($count_query)); $total_pages = $total_pages[num]; if ($sort == "date") { $targetpage = "ondemand.php?sort=date"; } if ($sort == "artist") { $targetpage = "ondemand.php?sort=artist"; } $limit = 5; $page = $_GET['page']; if ($page) { $start = ($page - 1) * $limit; } else { $start = 0; } //if no page var is given, set start to 0 /* Get data */ if ($sort == "date") { $query = "SELECT DATE_FORMAT(date, '%m/%d/%y' ) as fdate, id, image, headline, note, songs, audio_url FROM {$tbl_name} WHERE deleted = 'no' ORDER BY date DESC LIMIT {$start}, {$limit}"; } else { $query = "SELECT DATE_FORMAT(date, '%m/%d/%y' ) as fdate, id, image, headline, note, songs, audio_url FROM {$tbl_name} WHERE deleted = 'no' ORDER BY headline LIMIT {$start}, {$limit}"; } $result = mysql_query($query); if (!$result) { echo "error: " . $query; die('Invalid'); } /* Setup page vars for display. */ if ($page == 0) { $page = 1; } //if no page var is given, default to 1. $lastpage = ceil($total_pages / $limit); //lastpage is = total pages / items per page, rounded UP $lpm1 = $lastpage - 1; //last page minus 1 echo '<table class="ondemand">'; for ($i = 1; $i <= mysql_num_rows($result); $i++) { $info = mysql_fetch_assoc($result); on_demand_player($info['id']); } echo '</table>'; echo paginate($lastpage, $targetpage, $adjacents, $page, $lpm1); } else { $query = "SELECT DATE_FORMAT(date, '%m/%d/%y' ) as fdate, id, headline FROM {$tbl_name} WHERE deleted = 'no' ORDER BY headline, date DESC"; $result = mysql_query($query); if (!$result) { echo "error: " . $query; die('Invalid'); } echo '<table class="ondemand">'; for ($i = 1; $i <= mysql_num_rows($result); $i++) { $info = mysql_fetch_assoc($result); echo "<tr>\n<td>\n<a href=\"ondemand.php?id=" . $info['id'] . "\">" . $info['headline'] . "\n( " . $info['fdate'] . " )</a></td>\n</tr>\n"; } echo '</table>'; } //end of else sort == text }