michaelnaeseth
New member
I am accessing a MySQL database by using a small php script on my webserver. I have created a search function that is not working correctly. There are no results being displayed currently. Here is the code snippet
The script was working fine until my boss told me to implement a "exact match" or "broad match" variable. So I am positive all my variables are correct. I'm just missing something thats not obvious to a novice in php.
Code:
$srch = $_POST['search_by']; //db column to search
$srch_type = $_POST['search_type']; // exact or broad match search
$search = $_POST['query']; //search string
if ( $srch_type == "broad" ){
$srch_method = "LIKE" . "$search";
}
else {
$srch_method = "=" . "$search";
}
mysql_connect("host","username","pass");
mysql_select_db("db_name");
if ( $srch == "LastName" ){
$result = mysql_query("select * from user_records WHERE LastName '$srch_method'");
}
else if ( $srch == "ProjectAddress" ){
$result = mysql_query("select * from user_records WHERE ProjectAddress '$srch_method'");
}
The script was working fine until my boss told me to implement a "exact match" or "broad match" variable. So I am positive all my variables are correct. I'm just missing something thats not obvious to a novice in php.