|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Wildcard Searches on numeric column??
The situation is that I have a legacy DB that zero fills all of the numeric fields (it allows for 8 characters in the numeric field in questions so number 33 looks like 00000033). When we created the table we carried over the above format yet converted the data to numeric and zero filled. Thus it looks like the data from the legacy DB and we will be able to pass integrity audits. Anyway now I need to be about to search from a web page (enter wonderful PHP) on this column, but my users may not enter 00000033, they might just enter 33. The treatment of % in my SQL statement seems to make things fall apart as it is meant for strings not numbers. How might I handle a user input of 33 to find what is in the table as 00000033 ? Perhaps some cool built in that will auto zero fill this number? Right now I think I might just write a function to manipulate the user input (easy enough) but I am new to PHP and no need to reinvent the wheel if something already exists.
All thoughts and comments welcome! Thanks |
|
#2
|
|||
|
|||
|
RE: Wildcard Searches on numeric column??
Why don't you pad the number with 0's before you do your selection. If it's a fixed length field, then that shouldn't be too hard.
|
|
#3
|
|||
|
|||
|
RE: Wildcard Searches on numeric column??
Try this:
$zeropadded = sprintf("%08d", $input); |
|
#4
|
|||
|
|||
|
RE: Wildcard Searches on numeric column??
Thanks Matt that works wonderfully, however I might need to have my head checked. It appeared that this was not an issue. One of the beta testers cruised right through with no trouble looking up ID 00000033 as ID 33.
Howeber in the future for other items I know we are going to need something like this. Again Kudos Matt |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Wildcard Searches on numeric column?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|