SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    search from the first option that has been selected

    Hi guys

    My search is working quite well although I would like it to work like this

    At the moment you must select a category and then all options below will search within that category

    How about if a user selects a location and not a category. I want it search all the locations and the options below within that location

    And if a user only searches say a job status then it returns all jobs with that job status

    Hope that makes sense

    PHP Code:
    $query "SELECT *, date_format(startdate,'%d/%m/%Y') startdate FROM jobs WHERE 1=1  ";

    if (!empty(
    $category)) {
      
    $query .= "AND category='$category' ";
    }

    if (!empty(
    $location)) {
      
    $query .= "AND location='$location' ";


    if (!empty(
    $salarytype)) {
      
    $query .= "AND salarytype='$salarytype' ";
    }

    if (!empty(
    $salary)) {
      
    $query .= "AND salary >= $salary ";
    }

    if (!empty(
    $jobstatus)) {
      
    $query .= "AND jobstatus='$jobstatus' ";



    $query.= "ORDER BY '$order' ASC"

  2. #2
    SitePoint Addict
    Join Date
    May 2005
    Location
    London, ON
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah you're question isn't clear to me. Remember we haven't been working on your project. A little more explanation would be handy, along with the structure of your DB
    Ryan Price
    Subscribe to my blog for regular tips and tricks

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    your script already does what you appear to be asking...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my mistake had extra bit of code which checked for blank space


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •