ntroycondo Posted September 3, 2010 Share Posted September 3, 2010 I have a form passing user's search term, ie name. $pname = mysql_real_escape_string($pname; Not sure on proper syntax to include this in my select statement. I also want it to return for partial string matched, like 'mik' for 'mike': $result = mysql_query( "SELECT * FROM guest WHERE name like '$pname'" ); Quote Link to comment Share on other sites More sharing options...
muzzs Posted September 3, 2010 Share Posted September 3, 2010 Hi ntroycondo, This is a MySQL question really and so is in the wrong forum. What you need to use to get the desired result is the MySQL wildcard character (%), when this is used with the LIKE keyword, it is a wildcard for 0 or any number of characters. E.g. if you wanted it to allow partial strings that all start with the correct letters you will want: $result = mysql_query( "SELECT * FROM guest WHERE name like '$pname%'" ); Hope that helps! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.