I'm writing some PHP/MySQL code to do affiliate tracking based on the referral URL. Each affilate has already supplied the baseURL of their website. An affilate that has their own domain name would have a baseURL of
http://www.MyDomain.com but an affiliate that's on a free server might have a baseURL of
http://www.freeserver.com/mydir/
So, what I want to do is when somebody clicks through our homepage I take the referring URL (the URL where they came from) and compare it to the affilates' baseURLs to see which affiliate (if any) the visitor came from. Something like...
SELECT * from affiliate where baseURL WITHIN 'http://www.freeserver.com/mydir/home.html'
would match a row where baseURL is
http://www.freeserver.com/mydir/
SELECT * from affiliate where baseURL WITHIN 'http://www.freeserver.com/mydir/subdir/page6.html'
would also match a row where baseURL is
http://www.freeserver.com/mydir/
This way an affiliate can link to us from any page in their site and we know the referral came from them.
It's kind of the opposite of the LIKE function. With the LIKE function you start with a sub-string and match it to any string that has the sub-string within it. With the WITHIN function I'm looking for I am starting with the larger string and want to match it to any string that is a sub-string of it.
Is there a function that works like a "within" function?
- Paul