SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: OR problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    London
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OR problem

    Hi,

    I need some help with this query:

    SELECT *
    FROM myTable
    WHERE active = '1'
    OR fname LIKE '%#FORM.search#%'
    OR sname LIKE '%#FORM.search#%'
    OR company LIKE '%#FORM.search#%'

    I would like to select all records which have an active setting of 1 and match the form search submission. The problem is its selecting anything with an active status of 1 or a match to the form search submission.

    Any help would be much appreciated,
    Thanks,


    Richard

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Perhaps this can solve your problem?

    Code:
    SELECT *
    FROM myTable
    WHERE active = '1' AND
    ( fname LIKE '%#FORM.search#%'
      OR sname LIKE '%#FORM.search#%'
      OR company LIKE '%#FORM.search#%' )
    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    London
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats it thanks,

    Richard

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    san diego
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Formpage validation returns an auto respond email

    hi lilleman and rcuser

    I have a similar problem and I hope it's okay for me to continue on this thread and get some answers regarding PHP and MySQL functions. So with all respect may I ask if you know how to solve this:

    Question 1: If the validation of ENUM return a value of =0 from my select query,
    I want to send out an auto respond email. Based on this =0 result to those clients who haven't complete their submission.

    Question 2, is totally another issue but I give you a chance to figure this one out aswell: When I submit my form and save the info to the database and if it still missing information in certain fields. I want it to send an auto responded email request to the client and inform them that certain information is missing and needs to be send in for a complete submission.

    wow..hhu..headache.. did you got that? Can't explain it more clear than this.
    Any help would be much appreciated or any ideas that pointing in right direction. Thanks
    /rz

  5. #5
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1)
    Code:
    SELECT emailaddress 
     FROM yourtablename 
     WHERE enumfield = 0
    2a) First change your form to use javascript to prevent your form from being submitted without those fields filled out.

    2b) If you have already used this form then you want to contact those who have submitted the form but are missing info like you said:
    Code:
      SELECT emailaddress FROM yourtablename 
     WHERE importantfield1 is null 
     OR importantfield2 is null 
     OR importantfield3 is null

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    san diego
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dave
    The reason why I decided to put it in a new post was that the issue I have was slightly different than other one. I'm sorry I didn't saw your respond on this one before I did my last post in my own thread.
    Anyway this looks great. I really appreciate that you take your time and help me out. I'll try this and post the result.
    /rz

  7. #7
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problems. You are always best to start a new thread rather than bring up a new item in an old thread. Hope this solution works for you.


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
  •