> hi all....
> Is there a way to condition your search:
> -I have a form for four text boxes for search my Mysql...
> -I don't want to write 4 conditions and for SQL statements incase he
> decided not to search with all keywords (fields)
> - I have by example : name, lastname , nickname and phone form...
> I need a way to select my records even one or more field were null
> (searching only on of the above)
> because the following SQL will generate null result
> echo $name.$lastname.$nickname.$m_date;
> $sql = mysql_query("SELECT id, name , lastname , m_date from users where
> name like binary '%$name%' and lastname like binary '%$lastname%' and
> nickname like binary '%$nickname%' and m_date= YEAR('$m_date') order by
> id ASC ") or die(mysql_error());
> Thanks in advanced
Use isset to test whether the POST values are set and only include in the
query if there is a value.
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php