Jump to content

Archived

This topic is now archived and is closed to further replies.

DBookatay

Help with 'strlen' script

Recommended Posts

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?

Share this post


Link to post
Share on other sites
[code]
$last_six = substr($_POST['vin'], -6);
[/code]

Share this post


Link to post
Share on other sites
[!--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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.