SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict rabbitdog's Avatar
    Join Date
    Jul 2001
    Location
    So. Tenn.
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick coding question - dynamic queries

    if I'm building a query with an unknown number of field/value pairs in the where clause, is there a more graceful way of appending the appropriate ANDs to the statement than just adding it regardless and then stripping the last one off after the loop has executed?

    to illustrate: http://snapfire.com/index.phps
    Mr Vector
    High quality, royalty free, vector graphics
    for t-shirt artists and graphic/web designers.

  2. #2
    jigga jigga what? slider's Avatar
    Join Date
    Oct 2002
    Location
    Utah (USA)
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way you've done it seems pretty elegant, but wouldn't you want to do them as OR conditions? You could also look at concatenating them into a single variable and then appending them onto the query with an IN LIST or whatever the MySQL command is for a search list instead of multiple AND/OR conditions (seems the field you're searching on is always the same?).
    $slider = 'n00b';


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
  •