Jump to content

Multiple search field problem


davidycpsrep

Recommended Posts

Here is what I am trying to do...

I have a search page with 7 different search fields i.e. lastname, firstname, source,type ect. inside a form with a button called search. I have another page that is a table that shows all information unless a search is initiated then it shows the results. I got it working for 1 field (lastname) what I cant figure out is how to get it to work for all the fields. attached php of working file. Any help will be appreciated i can even paypal the genius who figures this out a few bucks.

I have tried the OR function in my query

$query_Search = "SELECT * FROM sales WHERE sales.last_name LIKE '%%$colname_Search%%'

OR sales.first_name LIKE '%%$colname2_Search%%'

didnt work

lastname search working at http://www.baricfunding.com/leadv2/

ORDER BY sales.dateoflead";

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/140088-multiple-search-field-problem/
Share on other sites

Overlooking the fact that your code is horribly written, way outdated, and very insecure, when you tried putting another variable into your query, did you actually set the variable? For example, for your first variable, you have this:

 

$colname_Search = "1";
    if (isset($HTTP_GET_VARS['searchLastName'])) {
    $colname_Search = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['searchLastName']
    : addslashes($HTTP_GET_VARS['searchLastName']);
}

 

Did you do that for your 2nd variable?

I did the following

 

 

$colname2_Search = "1";

    if (isset($HTTP_GET_VARS['searchFirstName'])) {

    $colname2_Search = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['searchFirstName']

    : addslashes($HTTP_GET_VARS['searchFirstName']);

 

 

 

}

 

I am teaching my self and I realize my code is sloppy.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.