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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:09:29+00:00 2026-05-27T16:09:29+00:00

I need some help displaying my results in PHP. Below is what displays for

  • 0

I need some help displaying my results in PHP. Below is what displays for my query:

SELECT service_names.id, service_names.name as service, service_titles.name 
as title,  user_id  FROM `service_names` INNER JOIN service_titles ON title_id 
= service_titles.id

enter image description here

The way the design is, I need to display the results like so:

<div class="list">
    <h3 class="secondary">Maintenance</h3>
        <ul>
            <li>Wiper Blades</li>
            <li>Air Filter</li>
            <li>Cabin Filter</li>
            <li>Fuel Filter</li>
            <li>Cooling System</li>
            <li>Brake System</li>
            <li>Fuel System</li>
            <li>Trans Fluid Exchange</li>
        </ul>
</div>
<div class="list">
    <h3 class="secondary">Tire Services</h3>
       <ul>
            <li>Tire Rotation</li>
            <li>Flat Repair</li>
            <li>Wheel Balance</li>
            <li>Wheel Alignment</li>
        </ul>
</div>

Here is my thread that I posted earlier which explains my database design and shows an image of what it needs to look like. So basically I have the database design in place but now I am not too sure how to create the query to loop through all the results and keep it in that HTML format posted above.

If anyone could help me I would really appreciate it.

Thanks!

  • 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-27T16:09:30+00:00Added an answer on May 27, 2026 at 4:09 pm

    I think something like this ought to do the trick, where you create an array for each ‘title’ which contains all the ‘service’ elements under that title… then you just loop through each of the ‘title’ arrays to generate the bullets:

    $query=mysql_query('',[DB_CONNECTION]);
    if (!$query){
        //do something  
    }
    if (!mysql_num_rows($query)){
        //do something for no results   
    }
    
    $result_array = array();
    
    while($r=mysql_fetch_array($query)){
        if (!isset($result_array[$r['title']])){
            $result_array[$r['title']] = array();
        }
        $result_array[$r['title']][] = $r['service'];
    }
    
    $html = "";
    foreach($result_array as $key => $value){
        $html .= "
        <div class=\"list\">
            <h3 class=\"secondary\">$key</h3>
                <ul>";
            foreach($result_array[$key] as $service){
                $html .= "<li>$service</li>\n"; 
            }
        $html .= "</ul></div>";
    }
    
    echo $html;
    

    This is structured so it will work for as many “title” types as you have. (Obviously you’d need to put in the sql and connection in the mysql_query() at the top.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help revising this. It keeps only displaying 0s as the temp.
i need some help and guidance in displaying the splitted Strings in order. let
I need some help posting some XML to a WCF service. In essence, the
I need some help with a group by mysql query clause. Medals Table (this
Need some help about with Memcache. I have created a class and want to
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help to solve this. I have a gridview and inside the gridview
Need some help with this problem in implementing with XSLT, I had already implemented
Need some help gathering thoughts on this issue. Our team is moving ahead with
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded

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.