> OK, here's a fairly standard, non-Oracle question for you all. A friend
> of mine has asked me to open up his part-search script a little bit by
> making it so that if someone searches for a part number 'cp7940'
> they'll get matching results that include dashes, such as 'cp-7940'.
I've considered a couple of different solutions to this. I think the most
elegant would be to use PHP to insert a % sign at the transition between the
letters and numbers. Consider this sample table:
mysql> select * from abc;
+----------+
| xyz |
+----------+
| sl-5500 |
| sl5600 |
| sl-6000L |
+----------+
mysql> select xyz from abc where xyz like 'sl%5500';
+---------+
| xyz |
+---------+
| sl-5500 |
+---------+
In PHP:
$out = preg_replace('/([a-zA-Z]+)-?([0-9]+)/', '\\1%\\2', $in);
This should work pretty quickly and have a minimum of false hits.
James
_____
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Spring Semester Begins Jan 31 -- New Classes Start Every Few Weeks.
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/