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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:19:20+00:00 2026-05-21T05:19:20+00:00

At the moment I’m using a WHERE loop to display 2 columns of information

  • 0

At the moment I’m using a WHERE loop to display 2 columns of information in my database. Here’s the code:

$sql2 = sprintf($rawsql2, mysql_real_escape_string($id));
$result2 = mysql_query($sql2);

/*These if & while statements decide whether or not the information should be displayed. If no results are returned from the query above then an alternative message is shown.*/

if (mysql_num_rows($result2) > 0) {
    while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) {
        echo $row["open"] . "-" . $row["close"] . "<br/><br/>";
    }
}
else {
    echo "Error";
}

This outputs the following:

08:00:00-12:30:00

13:30:00-16:30:00

09:00:00-17:00:00

18:00:00-20:00:00

09:00:00-17:00:00

18:00:00-20:00:00

08:00:00-17:00:00

18:00:00-20:00:00

09:00:00-17:00:00

18:00:00-20:00:00

Now, what I need to do is group every 2 lines that are turned so instead it would look like:

08:00:00-12:30:00 13:30:00-16:30:00

09:00:00-17:00:00 18:00:00-20:00:00

09:00:00-17:00:00 18:00:00-20:00:00

08:00:00-17:00:00 18:00:00-20:00:00

09:00:00-17:00:00 18:00:00-20:00:00

Is this possible? Thanks for any help

edit: Thanks for all the answers everyone…I used Shakti’s answer as it was the first one I saw but by the looks of it everyone’s are pretty similar.

  • 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-21T05:19:21+00:00Added an answer on May 21, 2026 at 5:19 am
    if(mysql_num_rows($result2) > 0)
    {
        $count=0;
        while ($row = mysql_fetch_array($result2, MYSQL_ASSOC))
        {    
            echo $row["open"] . "-" . $row["close"] ;
            if ($count % 2 !=0 )
            {
               echo  "<br/><br/>"; 
            } 
            $count++;    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

at the moment i am using a while (true) loop to do this. I
At the moment I am using the following bit of code to only get
At the moment I am using this code to insert text in a PDF:
At this moment i am using the code bellow to bring up a dialog
At moment I want to implement picture upload without using any plug-ins. My upload
At the moment I'm using strstr() for getting the first part of a string.
At the moment my code (PHP) has too many SQL queries in it. eg...
At the moment we use HSQLDB as an embedded database, but we search for
At the moment I have about 2000 trades which are priced using excel. I
At the moment I have a database with md5 passwords stored, a few years

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.