PDA

View Full Version : Adding dashes before searching DB


Bengal313
07-08-2003, 08:06 PM
I have a database that contain a searchable field called parcel_id. It is a 10 digit number. But the numbers are seperated by "-" (ex. 13-13-451-073). This caused me to get a incorrect search result. Is there a way in php to have the user input just he 10 digit number and before searching it would add the dashes in the appropriate places. (after the 2nd, 4th, and, 7th, numbers). That way I can make my search field to validate as "all numbers and max length of 10 digits). I'm sure this will give me accurate results.

If there is a way exactly in which page would I have to add the code.

Jason
07-08-2003, 09:03 PM
didn't you ask this exact same question before...why not use that answer you got before? Did it not work? Post some code....and at the same time for your answer, you add the code to the SQL query line...


Jason

Bengal313
07-08-2003, 09:24 PM
It didn't work for me. I still got incorrect results. I think if I did it this way it would alot simpler. Meaning if I force the user to enter all numbers and then add the dashes where needed. That way I don't have to worry about "if" . i am very new at this. I look to you guys for advise more than anything else. What kind of code would I have to write and where would I have to put it? Thanx

Jason
07-08-2003, 09:32 PM
well ok...just so you know, in the rules it says not to start a new thread on the same subject...but moving along...in your MySQL db you have to have a text field for the numbers since I don't think Integers can take the dashes...so in your php script you have an integer field that examines that a user enters exactly 10 digits, no more no less... you can parse like I said before..without the "if" statement and put it together in a string which would be allowed as a string in the db...


Jason

post your code...

Spookster
07-08-2003, 09:39 PM
Don't double post your questions. Just reply to the original one.

http://www.codingforums.com/showthread.php?s=&threadid=22567

Closing thread...