function searchFor($term, $start, $count, $appid) { $url = "http://boss.yahooapis.com/ysearch/web/v1/{$term}?appid={$appid}&format=json&start={$start}&count={$count}"; $session = curl_init(); curl_setopt($session, CURLOPT_URL, $url); curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($session, CURLOPT_CONNECTTIMEOUT, 2); $result = curl_exec($session); curl_close($session); $out = json_decode($result, true); $num = $out['ysearchresponse']['count']; $totalhits = $out['ysearchresponse']['totalhits']; for ($i = 0; $i < $num; $i++) { $abstract = $out['ysearchresponse']['resultset_web'][$i]['abstract']; $url = $out['ysearchresponse']['resultset_web'][$i]['url']; $title = $out['ysearchresponse']['resultset_web'][$i]['title']; $dispurl = $out['ysearchresponse']['resultset_web'][$i]['dispurl']; echo "<p><b><a href=\"{$url}\">{$title}</a></b> (<a href=\"{$url}\" target=\"_blank\">n</a>)<br />{$abstract}<br />{$dispurl}"; } $prev = $start - $count; $start = $start + $count; if ($count <= $totalhits && $prev >= 0) { echo "<div class=\"nav\"><a href=\"index.php?q={$term}&s={$prev}\"><< prev</a> (<a href=\"index.php\">home</a>) <a href=\"index.php?q={$term}&s={$start}\">next >></a></div>"; } else { if ($count <= $totalhits) { echo "<div class=\"nav\">(<a href=\"index.php\">home</a>) <a href=\"index.php?q={$term}&s={$start}\">next >></a></div>"; } } printFoot(); }
<div class="col-md-4"> <div id="ytplayer-songreqs"></div> </div> <div class="col-md-8"> <table class="table table-striped js-reqsongs-table"> <thead> <tr> <th>Title</th> <th>Duration</th> <th>Requested by</th> <th class="js-reqsongs-deletecol"></th> </tr> </thead> <tbody class="js-reqsongs-tbody"></tbody> </table> </div> </div><!--/.tab-pane --> <script>displayChannelReqsongs()</script> </div> <script>tabContentLoaded();</script> </div> </div> </div> <?php printFoot();