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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:37:14+00:00 2026-06-14T04:37:14+00:00

I have a website written in PHP with a search form. This site have

  • 0

I have a website written in PHP with a search form.
This site have lots of sections and mySql tables.

The client was complaining about the results because they were not grouped, and wanted them grouped according to the site section, like below:

Results in "About" Page:
<the results>

Results in "Blog":
<the results>

… and so on.

I had to implement a quick solution for it, so I made several queries and ran them separately… and used a foreach to iterate over the results and print them.

Well, it works, but I´m not happy about it, because it is quite slow and I wonder if I’ll have performance issues in the future.

I´m not a mysql genius myself and I just started my backend programmer carreer, so I wanted someone to give an idea of how I could handle this in a more professional way.

I was thinking of using a join, but I don’t know how I can group the results using this approach.

Any help would be very appreciated.

  • 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-14T04:37:15+00:00Added an answer on June 14, 2026 at 4:37 am

    I really doubt a join would help you in any way. Since you said that each of the section addresses a different table, there is no way you can join them whilst still making any sense. The best that you can do is writing these queries into one sentence and then take all the needed information in one go thus saving time on the data sending php <=> mysql since you will be executing once and returning once. Take a look here to see how you can do that. I really don’t think there is anything better at all that you could improve 🙂

    Response: Clearly, the more requests you are doing, the longer your script will perform. Have you ever tried using a command ping google.com in cmd? You see that even you send a very small amount of data, you cannot get the response faster than 30ms or so. This is the price that you pay for any request. Plus, it also the amount of data sent adds to the time. So executing it one by one you will make many unnecessary calls. Moreover you can always try it by yourself, it is not difficult to write it in either way. And output the time spent for the task. Repeat a few times. If the time spent sending data is very insignificant, you can just leave it the easy way. But keep in mind, if your application grows bigger, every lost millisecond will add up. Multiply it by one thousand requests and you could have lost a minute of your time or even more. Anyways, definitely don’t go the UNION way because you will most likely lose the most time analyzing the data you received. Either

    And about that function: I, myself, have never came up to need using that function so it is either me or you reading it – we would both read it from scratch. The only difference is that I knew such function existed 🙂 Weirdly enough, there is very little information on this. C# has datasets which are very good and make it easy to handle the data. PHP is slacking behind in my opinion :/ And I am all hands in C# now, so I tend to know less and less in php. If I were you, I would just copy paste the example from the link I gave and create a reusable class for later. Hope I helped at least a little bit 🙂

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

Sidebar

Related Questions

I have a website written in PHP and on this website, I use Andrew
I have the website written in PHP (Kohana) and MySQL. I want to create
I have a webapp written in PHP using a MySQL database backend. This question
I have a website that written with php and using mysql, I want to
So I have a members website written in PHP and MYSQL. Say for a
Our website code is written in PHP. We have very little testing in regards
All, I have a PHP website written in Zend Framework and MVC. Most of
I have a Website, which is built upon a CMS, written in PHP. And
I've written a website in PHP and it will have ability for users to
I have a website written in PHP (CakePHP) where certain resource intensive tasks are

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.