Exemplo n.º 1
0
function make_related_videos_table($episode)
{
    // two by season, two by category
    $related_set_season = get_related_videos_by_season($episode["Season"], $episode["EpNum"]);
    $related_set_category = get_related_videos_by_category($episode["Category1"], $episode["Category2"]);
    $output = "";
    $count = 1;
    $next_episode = mysqli_fetch_assoc($related_set_season);
    while ($next_episode && $count <= 2) {
        $output .= make_episode_cell($next_episode["EpID"]);
        $count++;
        $next_episode = mysqli_fetch_assoc($related_set_season);
    }
    $count = 1;
    $same_category_episode = mysqli_fetch_assoc($related_set_category);
    while ($same_category_episode && $count <= 2) {
        $output .= make_episode_cell($same_category_episode["EpID"]);
        $count++;
        $same_category_episode = mysqli_fetch_assoc($related_set_category);
    }
    return $output;
}
    die("Value not found. ");
} else {
    $total_episodes = mysqli_num_rows($episode_set);
    $pages = (int) ceil($total_episodes / $episodes_per_page);
}
$table = "";
if ($total_episodes == 0) {
    $table .= "No episodes found. ";
}
for ($page = 1; $page <= $pages; $page++) {
    $table .= "<script>console.log(\"pages:" . $pages . "\");</script>";
    $table .= "<script>console.log(\"total_episodes:" . $total_episodes . "\");</script>";
    $table .= "<script>console.log(\"total_episodes / episodes_per_page:" . $total_episodes / $episodes_per_page . "\");</script>";
    $episode = mysqli_fetch_assoc($episode_set);
    /* sometimes this thing will say it has more rows than there are acutally episodes, 
    	  this is coming from sql. I do this check here to stop the program from generating
    	  an unecesary page. */
    if ($episode) {
        $table .= "<ul class=\"medium-block-grid-4 episode_search_result_table\" id=\"episode_result_page_" . $page . "\"";
        $table .= ">";
        $count = 1;
        while ($episode && $count <= $episodes_per_page) {
            $table .= make_episode_cell($episode["EpID"]);
            $count++;
            $episode = mysqli_fetch_assoc($episode_set);
        }
        $table .= "</ul>";
    }
}
mysqli_free_result($episode_set);
echo $table;