PHP/MySQL multiple textbox's search one record

Posted on 2006-05-29
Last Modified: 2008-03-04
Ive got a php/mysql app that im tryin to search results on one record from up to 5 textboxes.

The results processor php page has this:

$query = ("SELECT * FROM tableA
WHERE contid LIKE '$contid%'
AND city LIKE '$city%'");

The PHP search form ive got 5 textboxes that i would like to be able to punch in up to 5
ID's in:
The actual record name in the table is contid.

Textbox1 name is contid
Textbox2 name is contid2
Textbox3 name is contid3 and so on up to 5

Can i put an AND/OR statement in the processor page to query also the contid2 and so on?

Any help would be appreciated, thanks

Question by:cybrthug
    1 Comment
    LVL 37

    Accepted Solution

    $query = ("SELECT * FROM tableA
    WHERE (contid LIKE '$contid%' OR
    contid LIKE '$contid2%' OR
    contid LIKE '$contid3%' OR
    contid LIKE '$contid4%' OR
    contid LIKE '$contid5%')
    AND city LIKE '$city%'");


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    This is a general how to create your own custom plugin system for your PHP application that you designed (or wish to extend a third party program to have plugin functionality that doesn't have it yet).  This is not how to make plugins for existing s…
    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now