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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:37:22+00:00 2026-05-21T16:37:22+00:00

Good day! Iam making a query wherein the parameters will be stored in the

  • 0

Good day!

Iam making a query wherein the parameters will be stored in the ARRAY. My code is as follows:

    $conditions = array();
    if ($event != ''){
        $conditions[] = "event LIKE '%$event%'";   //ERROR HERE?
    }
    if ($event_name != 'Choose Category') {
        $conditions[] = 'event_name = "'.$event_name.'"';
    }
    if ($event_startDate != '') {
        $conditions[] = 'event_startDate = "'.$event_startDate.'"';
    }
    if ($event_endDate != '') {
        $conditions[] = 'event_endDate = "'.$event_endDate.'"';
    }

    $query = "SELECT *
          FROM eventlist 
          WHERE event_share = 1".implode(' AND ', $conditions); //IS THIS CORRECT?

    $result = mysql_query($query) or die('Error: Query failed');

There’s already previous questions regarding this and i’ve already tried most of the answers there (I’ve tried so many combinations already). But still I cannot produce the results I desired. My first error is the LIKE.. Also, I am having error with my query statement. What I want is to combine all the parameters based on what user desired. If the user did not input any parameters, it will be catched by my IF statements.

Any suggestions will be highly appreciated. Thank you.

  • 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-21T16:37:23+00:00Added an answer on May 21, 2026 at 4:37 pm

    Your code above may generate somewhat query like as follows:

    $query = "SELECT *
              FROM eventlist 
              WHERE event_share = 1  event like '%xyz%' "
    

    that is you are missing AND before event…

    suggestions:
    1.) it would be better if you add some error code too
    2.) use following code for $query:

    $conditions[] = 'event_share = 1';
    $query = "SELECT *
              FROM eventlist 
              WHERE ".implode(' AND ', $conditions);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day all I have the following question: I would like to use Chart
Hello and good day to all. I have the following code to retrieve from
Good day, i will try and explain myself here. i am trying to create
Good day I am trying to query the names of employees who work on
Good day! I am writing a script as follows: var prev = 0; $(document).ready(function(){
Good Day, Assume that I am writing a Python-like range in C++. It provides
Good day, I am using CacheFilter to filter a certain path to my server
Good day everyone, I am building a page in ASP.NET, and using Master Pages
Good day everyone. I am working on a Firefox extension, and I want to
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We

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.