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

  • Home
  • SEARCH
  • 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 8598659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:12:24+00:00 2026-06-12T01:12:24+00:00

I have a table in the database and getting the output in my php

  • 0

I have a table in the database and getting the output in my php file like

I have a table ‘course’ in my database

id  semester   channel             course             coursecode       grade
1   Sem1      Channel1      Digital Networks             C70089          A
2   Sem1      Channel1      Network Theory               N00089          A+
3   Sem1      Channel2      Data & Structur              D70089          B
4   Sem1      Channel2      Object Oriented              C70089          A
5   Sem2      Channel1      Micro Processors             M70089          A
6   Sem2      Channel1      Electricals                  EE0089          B+
7   Sem2      Channel2      Elect & Communs              EC7080          C
8   Sem2      Channel2      Elect Labs                   LEO90           B+

How could I display dynamically either by table or div or ul. Could anyone suggest me simple way to do this designing

I think this is a silly question, as I tried in all the ways, I have come up here

   Sem1                                        Sem2
Channell                                       Channell
     Course       Course Code  Grade        Course            Course Code  Grade
Digital Networks    C70089     A           Micro Processors    -------      ---
Network Theory      N00089     A+          Electricals         -------      ---

Channel2                                       Channel2
Course            Course Code  Grade        Course            Course Code  Grade
Data & Structur     D70089     B           Elect & Communs       -----     -----
Object Oriented     C70089     A           Elect Labs            -----     -----
  • 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-06-12T01:12:25+00:00Added an answer on June 12, 2026 at 1:12 am

    Assuming you are using mysqli_* functions, your solution might look like this:

    CODEPAD – gives you your HTML.
    JSFIDDLE – styles your generated HTML, showing the end result.

    $query = mysql_query('SELECT * FROM course ORDER BY semester, channel');
    $semester = $channel = "";
    while($row = mysql_fetch_assoc($query))
    {
        if ($row["semester"] !== $semester)
        {
            if ($semester !== "")
            {
                echo "    </table>\n";
                echo "</div>\n";
            }
    
            $semester = $row["semester"];
            $channel = $row["channel"];
    
            echo "<div class=\"semester\">\n";
            echo "    <h3>{$semester}</h3>\n";
            echo "    <h3>{$channel}</h3>\n";
            echo "    <table>\n";
            echo "        <tr>\n";
            echo "            <th>Course</th>\n";
            echo "            <th>Course Code</th>\n";
            echo "            <th>Grade</th>\n";
            echo "        </tr>\n";
        }
    
        if ($row["channel"] !== $channel)
        {
            $channel = $row["channel"];
    
            echo "    </table>\n";
            echo "    <br />\n";
            echo "    <h3>{$channel}</h3>\n";
            echo "    <table>\n";
            echo "        <tr>\n";
            echo "            <th>Course</th>\n";
            echo "            <th>Course Code</th>\n";
            echo "            <th>Grade</th>\n";
            echo "        </tr>\n";
        }
    
        echo "        <tr>\n";
        echo "            <td>{$row["course"]}</td>\n";
        echo "            <td>{$row["coursecode"]}</td>\n";
        echo "            <td>{$row["grade"]}</td>\n";
        echo "        </tr>\n";
    }
    
    if ($semester !== "")
    {
        echo "    </table>\n";
        echo "</div>\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am getting problem as i have some data in a database tabel file
i have database table like this +-------+--------------+----------+ | id | ip | date |
that my problem: I have database table like that: id (AI) market_id 1 6
I have built a table from a MYSQL database using PHP. There are 4
My database table have a Timestamp column named as inTime and i am using
i have a database table of website links. i have another table of tags,
I have a table in database that is having some fields one of which
I have a database table with some rows that I want to fetch using
I have a database table containing dates (`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00').
I have a database table, my goal is to read in each of the

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.