DBookatay Posted May 20, 2006 Share Posted May 20, 2006 I am working on a site for an auto dealership where users can search based on certain criteria, one of which is the VIN number. I have this one input: [code]if($_POST['vin']) {$where[] = "vin = '{$_POST['vin']}'";}[/code] which works with the search script I was able to hack together, but what I want to do is also have the ability to search by the last 6 of the VIN. Meaning if a user enters all 17 alpha-numeric characters it returns a result, and as well if they only enter the last 6 characters of the vin... Does anyone have any idea how I can go about this? Quote Link to comment https://forums.phpfreaks.com/topic/10043-help-with-strlen-script/ Share on other sites More sharing options...
AndyB Posted May 20, 2006 Share Posted May 20, 2006 [code]$last_six = substr($_POST['vin'], -6);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10043-help-with-strlen-script/#findComment-37325 Share on other sites More sharing options...
DBookatay Posted May 20, 2006 Author Share Posted May 20, 2006 [!--quoteo(post=375398:date=May 19 2006, 08:12 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 19 2006, 08:12 PM) [snapback]375398[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]$last_six = substr($_POST['vin'], -6);[/code][/quote]I don't get it! How do I make it work based on the example I posted? Quote Link to comment https://forums.phpfreaks.com/topic/10043-help-with-strlen-script/#findComment-37331 Share on other sites More sharing options...
roxanerinard Posted May 20, 2006 Share Posted May 20, 2006 That should give you the last six numbers of the vin they are requesting. Then you could try iterating through the table and compare the last six numbers of every entry or try the LIKE operator in SQL (not sure if that would work). Quote Link to comment https://forums.phpfreaks.com/topic/10043-help-with-strlen-script/#findComment-37375 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.