SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with a dynamic WHERE statement

    Hello all.

    I was wondering if anyone could help me solve this problem.

    I have a HTML form returning the values $search_naam, $search_plaats and $search_stijl. This is my mySQL statement:

    Code:
    "SELECT * FROM winkels
     WHERE naam LIKE '%$search_naam%' AND plaats LIKE '%$search_plaats%' AND stijl LIKE '%$search_stijl%'
     ORDER BY naam, plaats DESC"
    What it should do is take the values from my HTML form, search the database for matches including the wildcards and display the results.
    Right now it just displays the whole database, disregarding everything entered in my form. The whole thing is used in a PHP script, but I thought it might simply be a mySQL problem.

    I'd be very glad to have this problem solved! I just cannot get my finger on it...
    Thanks in advance for the trouble!
    Jorg
    Webmaster www.bruised.nl

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    if you are getting all rows, then the values of the $variables are not being substituted into the sql string properly

    can you echo or display the sql after variable substitution, instead of executing it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The help (with more of the full script) continues on another SitePoint board:

    http://www.sitepoint.com/forums/show....php?p=1232195

    I can print() the values coming from the form. Thanks for the comment.
    Jorg
    Webmaster www.bruised.nl


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
  •