WHEREIS

<?php

header( "Content-type: application/vnd.ms-excel" );   

header( "Content-type: application/vnd.ms-excel; charset=utf-8");  

header( "Content-Disposition: attachment; filename = backuplist.xls" );   

header( "Content-Description: PHP4 Generated Data" );   



require_once '../config.php';

$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

if ($conn->connect_error) {

    die("Connection failed: " . $conn->connect_error);

}

$sql = "select assign,hostname,ip,org_path,cycle from backuplist"; 

$result = $conn->query($sql);


// 테이블 상단 만들기  

$EXCEL_STR = "  

<table border='1'>  

<tr>  

   <td>담당자</td>  

   <td>호스트명</td>  

   <td>아이피</td>  

   <td>백업 경로</td>  

   <td>백업 주기</td>  

</tr>";  

  

while($row = mysql_fetch_array($result)) {  

   $EXCEL_STR .= "  

   <tr>  

       <td>".$row['assign']."</td>  

       <td>".$row['hostname']."</td>  

       <td>".$row['ip']."</td>  

       <td>".$row['org_path']."</td>  

       <td>".$row['cycle']."</td>  

   </tr>  

   ";  

}  

  

$EXCEL_STR .= "</table>";  

  

echo "<meta content=\"application/vnd.ms-excel; charset=UTF-8\" name=\"Content-type\"> ";  

echo $EXCEL_STR;  


$conn->close();


?>



=======================================================================



config.php


<?php

const DB_HOST = 'localhost';

const DB_USER = '11';

const DB_PASS = '11';

const DB_NAME = 'BMS';

?>







이 글을 공유합시다

facebook twitter kakaoTalk kakaostory naver band
loading