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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:00:45+00:00 2026-06-15T22:00:45+00:00

I’m trying to do a Jquery Ajax search with multiple conditions, and this is

  • 0

I’m trying to do a Jquery Ajax search with multiple conditions, and this is my first time. I did some research and found ways to send data to a php file, however it’s only with one variable. I’m not sure how to implement all of my 6 variables into data: data.

here they are:

var FromDate
var ToDate
var MusicStyles
var Locations
var FromPrice
var ToPrice

Now here is where I got stuck, I should do a post with some data. When I have multiple variavbles, can I do data: dataFromDate, dataToDate, dataMusicStyles,?

$("#SearchButton").click(function() {

var dataFromDate            = 'dataFromDate='+ FromDate;
var dataToDate              = 'dataToDate='+ ToDate;
var dataMusicStyles         = 'dataMusicStyles='+ MusicStyles;
var dataLocations           = 'dataLocations='+ Locations;
var dataFromPrice           = 'dataFromPrice='+ FromPrice;
var dataToPrice             = 'dataToPrice='+ ToPrice;


            $.ajax({
                type: "POST",
                url: "do_search.php",
                data: dataFromDate, dataToDate, dataMusicStyles, dataLocations, dataFromPrice, dataToPrice,
                beforeSend: function(html) { // this happens before actual call
                    $("#results").html('');
                    $("#searchresults").show();
                    $(".word").html(searchString);
               },
               success: function(html){ // this happens after we get results
                    $("#results").show();
                    $("#results").append(html);
              }
            });   
});

Where the MySQL would look like this:

<?php
//if we got something through $_POST
if (isset($_POST['dataFromDate'])) {
    include('db.php');
    $db = new db();
    // never trust what user wrote! We must ALWAYS sanitize user input
    $word = mysql_real_escape_string($_POST['search']);
    $word = htmlentities($word);
    // build your search query to the database

    $sql = "SELECT
    events.ID,
    events.EVENT_NAME,
    events.start_datetime,
    events.end_datetime,
    events.VENUE_LOCATION,
    events.ENTRANCE_PRICE, 
    venues.VENUE_NAME,
    GROUP_CONCAT(music_styles.MUSIC_STYLE_NAME) AS MUSIC_STYLE_NAME
    FROM events
    INNER JOIN venues 
    ON events.VENUE_LOCATION = venues.ID
    INNER JOIN events_music_styles
    ON events.ID = events_music_styles.event_id
    INNER JOIN music_styles
    ON events_music_styles.music_style_id = music_styles.id
    WHERE start_datetime >= '$phpFromDate'
    AND end_datetime <= '$phpToDate' 
    AND ENTRANCE_PRICE >= '$phpFromPrice'
    AND ENTRANCE_PRICE <= '$phpToPrice' 
    GROUP BY events.ID";

    // get results
    $row = $db->select_list($sql);
    if(count($row)) {
        $end_result = '';
        foreach($row as $r) {
            $result         = $r['title'];
            // we will use this to bold the search word in result
            $bold           = '<span class="found">' . $word . '</span>';   
            $end_result     .= '<li>' . str_ireplace($word, $bold, $result) . '</li>';           
        }
        echo $end_result;
    } else {
        echo '<li>No results found</li>';
    }
}
?>

I am 100% certain that it doesn’t work like this, but I think I got it almost right. I would love it if someone could at least please let me know what I could do to fix the code.

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-06-15T22:00:46+00:00Added an answer on June 15, 2026 at 10:00 pm

    You send it as an object, like so:

    $.ajax({
        type: "POST",
        url: "do_search.php",
        data: {dataFromDate    : FromDate,
               dataToDate      : ToDate,
               dataMusicStyles : MusicStyles,
               dataLocations   : Locations,
               dataFromPrice   : FromPrice,
               dataToPrice     : ToPrice
        },
        beforeSend: function(html) { // this happens before actual call
            $("#results").html('');
            $("#searchresults").show();
            $(".word").html(searchString);
        },
        success: function(html) { // this happens after we get results
            $("#results").show();
            $("#results").append(html);
        }
    });​
    

    Where the firs value is the key, and the second is the value, so {key: value} would be accessed on the server as $_POST['key'], which your values would be accessed the way you seem to want :

    $_POST['dataFromDate']
    

    Also, you don’t need all those variables at the start, just use them directly in the object.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.