Basically, I am searching for specific ids that I have in my db. I am trying to display all of the ids that are in my search field regardless of any letters before or after the number.
so if I am searching for abc55cba I want my results to show record #55, #155, #255, #355, #455, #555...
Currently I can search 55abc and get the results that I want, but if I have any characters before the number, it will not bring back any results.
code:
$ids= $_POST['ids'];
SELECT id,description FROM class WHERE upper(details) LIKE upper('%$ids%') ORDER BY id DESC
search
Moderator: General Moderators
Re: search
I think you want a regular expression. Consider this one that removes all but digits:
And don't forget to call `mysql_real_escape_string()` before putting variables into your SQL.
Code: Select all
$ids = preg_replace('/\D/', '', $_POST['ids']);