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

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.

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");

You could use sprintf. …

AND prefix=" . sprintf('%04d',$details[$x]['tariff_prefix']) . "

No Luck my friend…! :frowning:

Again the same :blush: