Ok, I think I have a doozie here. What I am trying to do is have a page capture a variable from a form from a previous page. This is not the problem. The problem that I have is this:
I need this to search the table and use multiple fields. I have tried using the "select * from tablename where field1 or field2 or field3 like '%%s%%" blah blah. This does not work. It does not search it correctly. It pulls up a bunch of records that have absolutely nothing to do what was input. I have echoed the variable that is being passed into the statement, it has the correct data in the statement, so I figured that I was structuring the query incorrectly. Below is the snippet:
<?php
if (isset($HTTP_GET_VARS["query"])) {
$colname_QueryResult = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS["query"] : addslashes($HTTP_GET_VARS["query"]);
}
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$query_QueryResult = sprintf("SELECT * FROM products WHERE name LIKE '%%%s%%' ORDER BY name ASC", $colname_QueryResult);
$QueryResult = mysql_query($query_QueryResult, $mysqlconnect) or die(mysql_error());
$row_QueryResult = mysql_fetch_assoc($QueryResult);
$totalRows_QueryResult = mysql_num_rows($QueryResult);
?>
I have tried building each one like it was seperate query and using the ";" after the end of each string like you would if you were trying to do this mysql. I need this to search the following fields in the products table and return all that match:
1) name
2) description
3) category
4) itemcode
I have looked on the internet and cannot seem to find anything that works. Can this be done, or do I need to set up radio buttons on the previous page? The client that I am doing this for does not really want radio buttons, groups, or checkboxes, but if it cannot be done, then I am sure I can get them to overlook this.
I know that I can do this by building a seperate bind for each one individually and have it work like the first one, but I would really like to avoid this. I have thought about array's but do not know enough about them to try that just yet.
Thanks again,
Todd