Location: PHPKode > projects > Network Asset Management Archive > nama/liaso/importphone.php
<head>
<title>Import Phonebook</title>
</head>
<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";
$row = 1;
$handle = fopen ("stdetail.txt","r");
echo "<table border=2>";
echo "<th>Phone Ext</th><th>Name</th><th>Lab</th><th>Building</th><th>Room</th>";
while ($data = fgetcsv ($handle, 1000, ",")) {
    $num = count ($data);
    $num = 6;
    if ($data[0]!=0){
     if ( (($data[0]>4819) && ($data[0]<4900)) || 
          (($data[0]>1999) && ($data[0]<4320)) ||
          (($data[0]>4370) && ($data[0]<4491)) ||
          (($data[0]>4569) && ($data[0]<4690)) ) 
       {
       if (($data[1]=='Primary') && ($data[9]=='Active')) {
          print "<tr>";
//          print "<td>$num</td><td>$row</td>";
          $row++;
          for ($c=0; $c < $num; $c++) {
             if ($c!=1){
              if ($c!=2) {
                    print "<td>" . $data[$c] . "</td>";
              } else {
                    $poscomma = strpos($data[$c],",");
                    if ($poscomma==0) 
                    {   
                       $myname=$data[$c]; 
                    } else {
                       $name = explode(",",$data[$c]);
                       $myname = $name[0] . ", " . $name[1];
                    }
                    $posdash = strpos($myname,"-");
                    if ($posdash!=0)
                    { 
                       $name = explode("-",$myname);
                       $myname = $name[0] . " - " . $name[1];
                    }
                    $posdash = strpos($myname,"'");
                    if ($posdash!=0)
                    {
                       $name = explode("'",$myname);
                       $myname = $name[0] . "`" . $name[1];
                    }

                    print "<td>" . ucwords(strtolower($myname)) . "</td>";
                    $myname = ucwords(strtolower($myname));
                    $stmt="insert into phonebook (EXTENSION, NAME, OFFICESYM, BUILDING, ROOM) VALUES ('$data[0]','$myname','$data[3]','$data[4]','$data[5]');";
                    $sth=ibase_query($dbh, $stmt) or die($stmt);
                 
              }
             }
          }
          echo "</tr>";
       }
     }
    }
}
fclose ($handle);
echo "</table>";
?>
Return current item: Network Asset Management Archive