SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with comparision

    Hello

    I want to compare a text box value with the one stored in the mysql table. Here is the input of text box.

    HTML Code:
    352969678
    and the mysql table record is like

    HTML Code:
    352 969678
    a space is there after the first 3 digits. So i want to compare it via SQL.

    Suppose that the data from the text box is in $data and the column in table is "phone" so i want to do this (in PHP):

    HTML Code:
    "select * from some_table where phone = ".$data
    But it will not work as the data in the $data has not space after the first 3 digits while the record in table in database is having a space after the first 3 digits...

    Please help

  2. #2
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay I got the solution

    I can do it with MySQL Replace() function !

    Thanks

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    caution: this will result in a table scan

    the better idea is to stuff a blank into $data
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •