Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7600785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:59:50+00:00 2026-05-30T22:59:50+00:00

This is my first time creating php/mysql code from scratch and Im a little

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:59:52+00:00Added an answer on May 30, 2026 at 10:59 pm

    change ORDER BY season_num, sub_season_num to ORDER BY season_num, esp_num, sub_season_num

    $currentSeason = null;
    while ($row = mysql_fetch_array($result))
    {
    if($currentSeason !== $row->season_num){
    echo "Season $row->season_num";
    $currentSeason = $row->season_num;
    }
    
    echo "Episode {$row["esp_num"]}<br>";
    echo "Title {$row["title"]}<br>";
    echo "Description {$row["descrip"]}<br>";
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time creating a PHP form that will run a MySQL
I'm creating an asp.net MVC app, first time I've done this. I have a
This is the first time I'm creating an open-source project, and I've decided (based
This is my first time attempting to call an ASP.NET page method from jQuery.
This is my first time with Web services. I have to develop web services
this is my first time posting here, I have a question which I have
I'm creating an events website using PHP. I have a database with an events
This is my first time creating a has_and_belongs_to_many association and it is being less
This is my first time creating a SVN repository. I am running into problems
first time creating something like this. How would I create a hotbar type rectangle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.