|  |  | 
          
            | <?php $dsn ="IPP";
 $user = "";
 $pass = "";
 $IPaddress = $_POST{"IPaddress"};
 $Maxaddress = $_POST{"Maxaddress"};
 $Department = $_POST{"Department"};
 $Division = $_POST{"Division"};
 $User = $_POST{"User"};
 $Phone = $_POST{"Phone"};
 $SystemAdmin = $_POST{"SystemAdmin"};
 $connect = odbc_connect($dsn, $user, $pass) or die("ติดต่อ DSN ไม่ได้");
 $sql = "Select IPaddress From ipp Where IPaddress = '".$IPaddress."'";
 $exec = odbc_exec($connect, $sql);
 $num_rows = odbc_result($exec, 1);
 echo "<br>IPaddress = ".$num_rows."<br>";
 if ($num_rows ==0){
 
 $sql = "Select Maxaddress From ipp Where Maxaddress = '".$Maxaddress."'";
 $exec = odbc_exec($connect, $sql);
 $num_rows = odbc_result($exec, 1);
 echo "<br>Maxaddress = ".$num_rows."<br>";
 if($num_rows ==0){
 
 $sql = "insert into ipp (IPaddress, Maxaddress, Department, Division, User, Phone, SystemAdmin) values('$IPaddress', '$Maxaddress', '$Department', '$Division', '$User', '$Phone', '$SystemAdmin')";
 //echo "sql: ". $sql;
 $exec = odbc_exec($connect, $sql);
 echo "<Font Size=4 color=red><b>บันทึกข้อมูลเรียบร้อยแล้วครับ</b></Font>";
 echo "<Br><Br><A Href=\"ip3.php\">ดูข้อมูล</A>";
 echo "<Br><Br><A Href=\"ip1.php\">เพิ่มข้อมูลอีก</A>";
 echo "</B></Font>";
 odbc_free_result($exec);
 
 }else{
 echo "<Font Size=4 color=blue><b>Maxaddress นี้ซ้ำครับ..!!!!</b></Font>";
 }
 
 }else{
 echo "<Font Size=4 color=blue><b>IPaddress นี้ซ้ำครับ..!!!!</b></Font>";
 }
 //$sql = "select IPaddress, Maxaddress, User, Systemadmin From ipp";
 $exec = odbc_exec($connect, $sql);
 $num_fields = odbc_num_fields($exec);
 echo "<Table border=1><Tr>";
 For ($l=1; $l<=$num_fields; $l++)
 {
 echo "<td bgcolor=skyblue>".odbc_field_name($exec, $l)."</td>";
 }
 echo "</tr>";
 //end for
 $N=1;
 while (odbc_fetch_row($exec, $N))
 {
 $IPaddress = odbc_result($exec, "IPaddress");
 $Maxaddress = odbc_result($exec, "Maxaddress");//
 $User = odbc_result($exec, "User");//
 $SystemAdmin = odbc_result($exec, "SystemAdmin");//
 echo "<tr><td>$IPaddress</td><td>$Maxaddress</td> <td>$User</td> <td>$SystemAdmin</td></tr>";
 $N++;
 }
 //end while
 echo "</table>";
 
 echo "<Br><Br><A Href=\"ip1.php\">เพิ่มข้อมูลอีก</A>";
 echo "<Br><Br><A Href=\"ip3.php\">ดูข้อมูล</A><br><br>";
 
 Function Contact()
 {
 echo date("d/m/"), date("Y")+543, ", ", date(" H:i:s");
 }
 Contact();
 ?>
 จุดประสงคือตรวจสอบและบันทึกหมายเลยไอพี ถ้าซ้ำให้แสดงออกมาเป็นรูปตารางว่า IPaddress Maxaddress ที่ซ้ำนี้มีผู้ใช้ คือ User SystemAdmin คือใคร ครับ
 รูปแบบตารางแบบนี้นะครับ
 IPaddress .........................
 Maxaddress...................
 User..........................
 SystemAdmin.............
 
 ครับ รบกวนท่านผู้รู้ PHP ช่วยผมด้วยครับ
 
 
 
 Tag : - - - -
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          3 ส.ค. 2548  08:48:11 | By :
                          มือใหม่ | View :
                          2638 | Reply :
                          6 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |