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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:27:58+00:00 2026-06-10T12:27:58+00:00

My PHP application has the function product_fetch([parameters]) which returns ‘Product’ objects which information are

  • 0

My PHP application has the function product_fetch([parameters]) which returns ‘Product’ objects which information are stored in database.

In my admin area, there is a page called “Featured Products” which allows me to select 10 products to be displayed in the main page.

Now comes the problem: I made 10 select/combobox, each allows me to select one product, out of 400. So in order to make all the options, a query has to be made: SELECT * FROM products

Question: Is it correct to make such a query, even though there’s hundreds of rows?

  • 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-10T12:28:00+00:00Added an answer on June 10, 2026 at 12:28 pm

    You would be much better of specifying which produts you want in the query and only returning those if you have no intention of using any of the others at all.

    You can do this using many methods. A simple one would be using an ID field in an in statement like this:

     select col1, col2 from products where id in(1,4,12,5)
    

    It might seem to make little difference, but what if your procuts table had a hundred thousand rows in it?

    You could also have a flag in the table to say that the items are featured which would let you use something like this:

    select col1, col2 from products where featured='Y'
    

    Or you could even have a table that only has featured items (even just their ID) and join it to your main listing like this:

    select
        a.col1,
        a.col2
    from
        products a
            join featured b
                on a.id=b.id
    

    If you want to pick through your whole table, you can even use a simple limit clause that picks up a certain number of rows from the table and can be reused to get the next set:

    select col1, col2 from products limit 10;
    // Will pick the first 10 rows of data.
    
    select col1, col2 from procuts limit 30,10;
    // Will pick rows 31-40 (skipping first 30, then returning next 10)
    

    The short version is though, no matter how you do it, pulling back a whole table of data to pick through it within PHP is a bad thing and to be avoided at all costs. It makes the database work much harder, uses more network between the database and PHP (even if they are on the same machine, it is transferring a lot more data between the two of them) and it will by default make PHP use a lot more resources to process the information.

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

Sidebar

Related Questions

I have a PHP application, which has a delete function on one of the
I have a PHP application that has passwords stored in the database as the
We are working with a PHP application which has no concept of switch-able themes;
As the title suggests, I've inherited a php/MySQL application which has fairly well written
I'm using the Yii PHP framework which has a function PDO::lastInsertId that's apparently just
Has anyone seen this error when working with a PHP application out of dynamic
I've got a very old php application (1999) that has been worked on during
Problem: Blank email from PHP web application. Confirmed: App works in Linux, has various
I have a jar file of my application which has more than one class.
I have this query which I want to run in my PHP application back

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.