So I am looking to pull contact names and phone numbers from a MySQL database and strip any extra formatting and then write them to XML that our VoIP phones can read. I have figured out how to clean the data up and how to write everything to a XML. What I amstruggling with is piping the MySQL queries into my code that cleans up the numbers and then writes the XML. Below is sampling of the code I have for cleaning and writing to XML, instead of manually assigning the variables as I have done for testing of my current code, I would like to pipe in data from a MySQL query. I know how to echo MySQL out but I am struggling with this…
[php]
$name = ‘TestUser1’;
$dirtynumber = ‘(520) 555-2179’;
$databasequeryresult = $dirtynumber;
$number = $databasequeryresult;
$remove = array("(", “)”, “-”, " “);
$new = array(”", “”, “”, “”);
$cleannumber = str_replace($remove, $new, $number);
$file = ‘store1mgrs.xml’;
$entry = “\n $name”;
file_put_contents($file, $entry, FILE_APPEND | LOCK_EX);
$file = ‘store1mgrs.xml’;
$entry = “\n $cleannumber”;
file_put_contents($file, $entry, FILE_APPEND | LOCK_EX);
$file = ‘store1mgrs.xml’;
$entry = “\n $cleannumber1”;
file_put_contents($file, $entry, FILE_APPEND | LOCK_EX);
$file = ‘store1mgrs.xml’;
$entry = “\n $cleannumber2”;
file_put_contents($file, $entry, FILE_APPEND | LOCK_EX);
[/php]