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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:11:55+00:00 2026-06-12T08:11:55+00:00

On one of my PHP sites, I need to offer my Users the ability

  • 0

On one of my PHP sites, I need to offer my Users the ability to select certain rows to exclude from all search results (queries) on the site.

Which way should I go about handling the exclusions, should I:

1) Pre-compile that list of excluded rows whenever the user logs in (or updates it) by querying it, save the list in a Session variable, and then simply add $query .= " AND userid NOT IN ({$_SESSION['ExclusionList']})" to every search query on the site,

or

2) Compile it always on-the-fly directly in each query by simply adding $query .= " AND userid NOT IN (SELECT userid FROM Excluded WHERE excludedBy = '$currentUserID')" to every search query on the site?

Method 1) seems more efficient since I’m only compiling the list once when the user logs in (or whenever they update it), rather than having to essentially compile the list every time any user runs a search query on the site.

What do you suggest and why?

  • 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-12T08:11:56+00:00Added an answer on June 12, 2026 at 8:11 am

    Technically this would be called “caching” the values and it’s not a bad idea provided the lists don’t get too huge or your $_SESSION could end up being kind of heavy-weight.

    Doing a sub-select can be very expensive, especially on large sets of records, so you’re usually better off caching it.

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

Sidebar

Related Questions

Should one need to learn php(or jsp) to create dynamic web-sites or just to
How can I save data from one site to another sites database? I need
I have urls such as /blah/WHATEVER/sites/two/one/blah/need/this.ini in PHP, how do I extract /need/this.ini with
In one of my sites, I need to use PHP 'foreach' to keep including
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Iam working on Ubuntu.(Linux) I want to redirect from the page one.php to two.php,
I need to call via Ajax a routine on my PHP server from my
I need to make sure that PHP sites that I administrate, don't have any
I need a rewrite rule that will do an internal redirect from: <domain>/directory/<anything>/<anything>.php to:
General question. One of my sites is on a LAmP server and I need

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.