Forum Moderators: coopster
When constructing a simple search form, with perhaps a single field called "Last Name." I want the user to be able to enter perhaps just the first letter of the last name and have the search results return all matching records. For example: Last Name = c
Returns...
Collins
Compton
Copperton
Obviously the following code returns data that "Is equal to" the data. Which would be a lastname that is the letter C.
$sql = "select * from Tablename where Lastname=\"C\"";
In PHP how do you code it for things like...
begins with
contains
is equal to
is not equal to
etc.
If you know if a good primer or another forum already discussing this, I'd love a link to it. Like I said I keep trying to search for keywords that I think describe this and I come up with nothing.
Thanks!
Scott
or LIKE 'c%' if the name starts with c. like chris.
! is equal to no. so,
"select * from Tablename where Lastname!= 'Chris' would return all entries except chris.
why not look at the php code generated by phpMyAdmin, or the mysql manual itself?
[dev.mysql.com...] (for english version)
you don't need \"\" in a query.