SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select Number with Zero infront from database

    I am in a big problem. I have created a VOIP billing system, in this system, I used to bill a call destination using international prefix code eg : 001 for US and 0091 for India and all.

    But the people who are using this system used to add different rates for 0091 and 91, so in some cases the rate calculation is wrong.

    I am selecting the rate using the prefix.

    So can anyone please help me ?

    Thanks

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like you have choosen an integer or other numeric data type, when you should be using a character data type. Change it.


    edit- maybe you already are using a character data type. See str_pad() to left pad with zeros.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what should I change here :

    $sql = mysql_query("SELECT voice_rate FROM tariffs WHERE id_tariff =" . $details[$x]['id_tariff'] . " AND prefix=" . $details[$x]['tariff_prefix'] . " LIMIT 1");

  4. #4
    SitePoint Member
    Join Date
    Feb 2010
    Location
    Texas
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use sprintf. ...
    PHP Code:
    AND prefix=" . sprintf('%04d',$details[$x]['tariff_prefix']) . " 
    ...

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by F00Baron View Post
    You could use sprintf. ...
    PHP Code:
    AND prefix=" . sprintf('%04d',$details[$x]['tariff_prefix']) . " 
    ...
    No Luck my friend..........!

    Again the same


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
  •