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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:51:52+00:00 2026-06-17T17:51:52+00:00

my table is named as pank i know how to connect to the database

  • 0

my table is named as pank
i know how to connect to the database but following programming is giving me problem

my table is:

id| stream  |     title           |  cast | director

1 | stream1 | title of the movie1 | cast1 | director1

2 | stream1 | title of the movie2 | cast2 | director2

3 | stream2 | title of the movie3 | cast3 | director3

My PHP script:

$query  = "SELECT * FROM pank";
$result = mysql_query($query); 

while ($row = mysql_fetch_array($result))
{
    echo "<h2>".'Stream : ', $row['stream'], "</h2>",
         "<br />",
         "<h3>", 'Title of the movie  : ', $row['title'], "</h3>",
         "<h3>", 'cast : ', $row['cast'], "</h3>",
         "<h3>", 'director : ', $row['director'], "</h3>"
        ;
}

I want output as:

stream1

title of the movie1
cast1
director1

title of the movie2
cast2
director2


stream 2 

title of the movie3
cast3
director3

the above php is giving output as:

stream1
title of the movie1
cast1
director2

stream1
title of the movie2
cast2
director2


stream2 
title of the movie 3
cast3
director3

I just don’t want output labeled as stream1 again second time

  • 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-17T17:51:53+00:00Added an answer on June 17, 2026 at 5:51 pm
    <?php
    
    $query="SELECT * FROM pank order by stream"; // make sure the result groups all streams together
    $result=mysql_query($query); 
    
    $currentstream = null; // create a container to record the current stream
    while($row = mysql_fetch_array($result))
    {
        // If this entry's stream is different from the current, display it, 
        // and reset the current stream variable
        if($row['stream'] != $currentstream){ 
            echo "<h2>".'Stream : '. $row['stream'] . "</h2>";
            $currenstream = $row['stream'];
        }
        echo "<br />";
        echo "<h3>" .'Title of the movie  : '. $row['title'] . "</h3>";
        echo "<h3>" .'cast : '. $row['cast'] . "</h3>";
        echo "<h3>" .'director : '. $row['director'] . "</h3>";
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following table named [clients] with columns and values as follows: +--------+-----------+--------------+----------------+
I have a database table named Categories . I want to create a form
I have a table named with Sales having the following columns: Sales_ID|Product_Code|Zone|District|State|Distributor|Total_Sales Now i
I have one table named task_assignment . It has following 6 fields named as:
I have a database table named author and when someone sign up and then
In my SPROC a table named #temp1 contains the following columns: #temp1 (StoreId, StoreDesc,
Suppose I have a table named [ProductPriceHistory] like the following: HistoryID..ProductCode..EffectDate.... Price.... IsActive...ProductName 1----------11-----------1
I have a table named department , which has following data DNO DNAME SALARY
I have a a table named books containg fields as book_id | title |
My table named as sales . It contains the column like the following. fld_id

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.