I'm working on a project (lord knows why, I'm a below average coder) where I need to identify a phone number and its country code and national code to obtain the billing info..
I have been able to obtain the the country code without problems, but I'm having problems getting the national calling code.
I have 2 ways to do this, either way I need to take the full number from my database, find the country code, then do a substr(full number, country code length, 10*) and decrement it until I either find a match or 10 counts down to 0, after which I can select the id from the database using the country code and the national code as NULL.
The first way is to do a query for each decremented number, until it either hits, or ends up querying for NULL, the other way is to take all the matches for the country code (except for NULL) and create an array (at most I've seen 60 records). I then want to look for the decrementing number in the array.
I wanted to see which method was more efficient, but for some reason I'm not populating my array properly (at least as far as I can tell.. I'm not even 100% on how to do that).
My question is, am I doing it wrong?
$query2 = "select nspec from routing_codes where ccode = '$true_cc' and nspec IS NOT NULL"; //grab all nspec codes to fill array
$result = mysql_query($query2) or die('Query1 failed: ' . mysql_error());
$totalRows = mysql_num_rows($result);
$tf_result = array();
for ($j=0; $j<$totalRows; $j++) {
$tf_result[$j] = mysql_fetch_row($result);
}
* For some reason orange has a 10 digit national calling number in the UK, otherwise 6 is the usual length... I'll probably test for the UK cc, and adjust the length accordingly when I get the damn thing functioning correctly.