CyberPirate
07-28-2012, 09:41 PM
Hello!
I've been tinkering with PHP again and this new MySQLi, it's cool what happens when you're on hiatus for two or more years :)
I'm trying to list all episodes in a TV show into separate seasons, but I can't figure out the correct approach.
This is my current code:
<?php
$getSerieID = mysqli_real_escape_string($conn, $_GET['id']);
$getSerie = mysqli_query($conn, "SELECT * FROM episode, program WHERE episode.program_id = '$getSerieID' AND program.program_id = '$getSerieID' ORDER BY sesong_id, episode_id ASC") or die(mysqli_error($conn));
$printSerie = mysqli_fetch_array($getSerie, MYSQLI_ASSOC);
echo "\t<b>" . $printSerie['navn'] . "</b><br>\n";
echo "\t" . $printSerie['beskrivelse'] . "<br>\n";
mysqli_data_seek($getSerie, 0);
while ($printSerie = mysqli_fetch_array($getSerie, MYSQLI_ASSOC))
{
echo "\t" . $printSerie['episode_navn'] . "<br>\n";
}
?>
I would like to get a result looking like this:
Season 1
- 1
- 2
- 3
Season 2
- 1
- 2
- 3
Help is much appreciated :)
I've been tinkering with PHP again and this new MySQLi, it's cool what happens when you're on hiatus for two or more years :)
I'm trying to list all episodes in a TV show into separate seasons, but I can't figure out the correct approach.
This is my current code:
<?php
$getSerieID = mysqli_real_escape_string($conn, $_GET['id']);
$getSerie = mysqli_query($conn, "SELECT * FROM episode, program WHERE episode.program_id = '$getSerieID' AND program.program_id = '$getSerieID' ORDER BY sesong_id, episode_id ASC") or die(mysqli_error($conn));
$printSerie = mysqli_fetch_array($getSerie, MYSQLI_ASSOC);
echo "\t<b>" . $printSerie['navn'] . "</b><br>\n";
echo "\t" . $printSerie['beskrivelse'] . "<br>\n";
mysqli_data_seek($getSerie, 0);
while ($printSerie = mysqli_fetch_array($getSerie, MYSQLI_ASSOC))
{
echo "\t" . $printSerie['episode_navn'] . "<br>\n";
}
?>
I would like to get a result looking like this:
Season 1
- 1
- 2
- 3
Season 2
- 1
- 2
- 3
Help is much appreciated :)