Guest User

Untitled

a guest
Dec 14th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. $username = "root";
  3. $password = "xyz";
  4. $hostname = "localhost";
  5.  
  6. $dbhandle = mysql_connect($hostname, $username, $password)
  7. or die("Unable to connect to MySQL");
  8. echo "Connected to MySQL<br>";
  9.  
  10. $selected = mysql_select_db("xyz",$dbhandle)
  11. or die("Could not select examples");
  12.  
  13. $row = 1;
  14. $file = fopen("check_tollfree_result.csv","w");
  15.  
  16. $sql = "select number from dids";
  17. $result = mysql_query($sql);
  18.  
  19. while($row1 = mysql_fetch_assoc($result)) {//echo "number: " . $row1["number"]. "<br>";
  20. $phoneno = $row1["number"];
  21.  
  22. if (preg_match("/(\+?1)?(8(00|44|55|66|77|88)[2-9]\d{6})/", $phoneno)){
  23.  
  24. $query = 'select count(billseconds) as minutes from cdrs where callednum="'.$phoneno.'" and callstart >= "2018-11-01 00:00:00" and callstart <= "2018-11-30 23:59:59"';
  25. echo $query."\n";
  26. $result_qur = mysql_query($query);
  27. while($rowcount = mysql_fetch_assoc($result_qur)) {
  28. $Total_minutes = $rowcount["minutes"];
  29. $line = $phoneno .",". $Total_minutes;
  30. }
  31. fputcsv($file , explode(',',$line));
  32. }else{
  33. $line2 = $phoneno .",". "NOT Matched";
  34. }
  35.  
  36.  
  37.  
  38. }
  39.  
  40. fclose($file);
  41. fclose($file2);
Add Comment
Please, Sign In to add comment