cottonbuds2005 Posted October 16, 2009 Share Posted October 16, 2009 Please bear with me because Im a newbie at SQL / PHP stuff. My database is an inventory of all our PC equipment. What I want to do is make a search for a serial number with wildcard strings at the end. example: when I enter the serial number LVW9 I want the results for all PCs having sn starting with that string. Like LVW9237, LVW9228 etc etc The code below allows just the exact sn for the PC. How to do this? Please help me. ___________________________________________ mysql_select_db($database_ITInventory, $ITInventory); $query_SearchSerial = sprintf("SELECT * FROM assetsdb WHERE SerialNo = %s", GetSQLValueString($colname_SearchSerial, "text")); $SearchSerial = mysql_query($query_SearchSerial, $ITInventory) or die(mysql_error()); $row_SearchSerial = mysql_fetch_assoc($SearchSerial); $totalRows_SearchSerial = mysql_num_rows($SearchSerial); Link to comment https://forums.phpfreaks.com/topic/177857-simple-sql-search-question-pls-help/ Share on other sites More sharing options...
kickstart Posted October 16, 2009 Share Posted October 16, 2009 Hi To use wild cards use a LIKE instead of an =, and then use the appropriate wild card for your search (ie, % for zero or more characters, _ for a single character, etc). All the best Keith Link to comment https://forums.phpfreaks.com/topic/177857-simple-sql-search-question-pls-help/#findComment-937929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.