This is my first time creating php/mysql code from scratch and Im a little lost. I have a tv show I created a mysql database for. My problem is creating the php code that groupies, orders, then echos the database into seasons and episodes.
The question is, how to group my episodes into seasons and then echo them and make sure they are in the correct descending order?
Example
Season 1
Eps 1
Eps 2
Eps TBA sub_season_num 3
Season 2
Eps 1
Eps 2
ect…
My code is as follows right now.
function showerror()
{
die("Whoops " . mysql_errno() . ":" . mysql_error());
}
if (!($result = mysql_query("SELECT season_num, sub_season_num, esp_num, title, descrip FROM season ORDER BY season_num, sub_season_num", $link))) showerror();
echo "Season 1";
while ($row = mysql_fetch_array($result))
{
echo "Episode {$row["esp_num"]}<br>";
echo "Title {$row["title"]}<br>";
echo "Description {$row["descrip"]}<br>";
}
My sql database has the following table “season” inside are the following “ID” “season_num” “sub_season_num” “esp_num” “title” “descrip”
Some “esp_num” have a value of (TBA) so I use “sub_season_num” to help order them until an episode number is assigned.
Any help and/or code samples would be greatly appreciated.
change
ORDER BY season_num, sub_season_numtoORDER BY season_num, esp_num, sub_season_num