Superwormy
Golden Member
Below is what I want to do, its PHP code:
SELECT * from $tablename where (name='$search_name' and email='$search_email')";
Problem being, if the user only wants to enter $search_name or only $search_email, it won't find anything because it'll be searching for, for instance, entries with the name: Keith AND email:
And it won't find anything because all entires with Keith also have email addresses. Is there a mysql thing I can put in there and say if $search_email == "" (ie nothign entered) then $search_email = (mysql character meaning everything I guess...) so that mysql with search for:
name == Keith AND email == (any email)
Did all the make sense? Anyone?
SELECT * from $tablename where (name='$search_name' and email='$search_email')";
Problem being, if the user only wants to enter $search_name or only $search_email, it won't find anything because it'll be searching for, for instance, entries with the name: Keith AND email:
And it won't find anything because all entires with Keith also have email addresses. Is there a mysql thing I can put in there and say if $search_email == "" (ie nothign entered) then $search_email = (mysql character meaning everything I guess...) so that mysql with search for:
name == Keith AND email == (any email)
Did all the make sense? Anyone?