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 7445869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:08:53+00:00 2026-05-29T12:08:53+00:00

I have an array $eps coming from MYSQL table and I want to output

  • 0

I have an array $eps coming from MYSQL table and I want to output the content of it into below html format. I tried to use foreach loop to output the contents but value of season is wrapping over all the details div.
Below code is what I can only think of

foreach($eps as $key){
    foreach($key as $k){
    echo "<div class='main'>";
        echo "<div class='season'>".$k['season'];
            echo "<div class='details'>";
                echo "<div class='ep'>".$k['episode']."</div>";
                echo "<div class='title'>".$k['title']."</div>";
                echo "<div class='airdate'>".$k['airdate']."</div>";
                echo "<div class='plot'>".$k['plot']."</div>";
            echo "</div>";
        echo "</div>";
    echo "</div>";
    }
}

Array contents

Array
(
    [1] => Array
        (
            [0] => Array
                (
                    [title] => Pilot: Part 1
                    [date] => Sep. 22, 2004
                    [plot] => Forty-eight survivors of an airline flight originating from Australia, bound for the 
                    [season] => 1
                    [episode] => 1
                )

            [1] => Array
                (
                    [title] => Pilot: Part 2
                    [date] => Sep. 29, 2004
                    [plot] => Jack, Kate and Charlie return to the group, but the transceiver is broken. Sayid Jarrah 
                    [season] => 1
                    [episode] => 2
                )
    [2] => Array
        (
            [0] => Array
                (
                    [title] => Man of Science, Man of Faith
                    [date] => Sep. 21, 2005
                    [plot] => One of the castaways is chosen to descend into the mysterious hatch, and Shannon stumbles 
                    [season] => 2
                    [episode] => 1
                )

            [1] => Array
                (
                    [title] => Adrift
                    [date] => Sep. 28, 2005
                    [plot] => After the raft explodes, Michael and Sawyer are left on what is left on the raft. They 
                    [season] => 2
                    [episode] => 2
                )

CSS

.main {
    width: 750px;
    margin-right: auto;
    margin-left: auto;
    clear: both;
    overflow:auto;
}
.season {
    margin: 5px;
    padding: 5px;
    width: 730px;
    background: #960;
    clear: both;
    overflow:auto;
    display: block;
}
.details {
    display: block;
    float: right;
    border-bottom: thin solid #000;
}
.ep, .title, .airdate, .plot {
    margin: 5px;
    padding: 5px;
    width: 675px;
    background: #CCC;
}
  • 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-29T12:08:56+00:00Added an answer on May 29, 2026 at 12:08 pm

    Only 1 occurance of an ID per document…. You know that, righ? Made them classes.

    //only 1 main per total result, so, outside foreach.
    echo "<div class='main'>";
    foreach($eps as $key){
        //one season per sub array, so outside the other foreach:
        echo "<div class='season'>".$key[0]['season'];
        foreach($key as $k){
                echo "<div class='details'>";
                    echo "<div class='ep'>".$k['episode']."</div>";
                    echo "<div class='title'>".$k['title']."</div>";
                    echo "<div class='airdate'>".$k['airdate']."</div>";
                    echo "<div class='plot'>".$k['plot']."</div>";
                echo "</div>";
        }
        echo "</div>";
    }
    echo "</div>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array data as shown below, I want to store 'sale' value into
I have array in following format. I want to convert it into another format
I have array of image url. I want to show the images into UIImageView.
I have array of countries. I want to pick 5 random countries from my
I have array number = {2,3,4,5,6} Now i have to select rows from table
I have array like below the page. I want to find array number which
VISUAL C++ Question Hi, I have array of 3 elements and I want to
I have array like below, Array ( [14289] => Array ( [0] => Karthikeyan
I have array of chars: char macChars=[12]; The content of it is e.g. macChars[0]=53,
I have array that element is hash a = [{:history_date=>15/07/10}, {:open_price=>7.90}] I want to

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.