$ su
# yum install php-mysql
# service httpd stop
# service httpd start
# service mysqld stop
# service mysqld start
2.MySQLにデータベース,テーブル作成
$ mysql -u root -p
create database sa;
$ vi server_list.csv
,1,sa000,10.2.3.100
,2,sa001,10.2.3.101
,3,sa002,10.2.3.102
,4,sa003,10.2.3.103
,5,sa004,10.2.3.104
,6,sa005,10.2.3.105
,7,sa006,10.2.3.106
,8,sa007,10.2.3.107
,9,sa008,10.2.3.108
,10,sa009,10.2.3.109
,11,sa010,10.2.3.110
,12,sa011,10.2.3.111
$ mysql -u root -p sa
create table server_list ( id integer NOT NULL AUTO_INCREMENT PRIMARY KEY, num char(4), host_name char(20), ip_address char(15) ); show tables; load data local infile "~/server_list.csv" into table server_list fields terminated by ',' enclosed by '"' lines terminated by '\n'; select * from server_list;
3.Windows側でPHPファイルを作成
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>server_list</title> </head> <body> <?php $db_user = "[user name]"; $db_password = "[password]"; $db_name = "[database name]"; $db_host = "localhost"; $db = mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_name,$db); $str_sql = "select * from server_list"; $rs = mysql_query($str_sql,$db); $num = mysql_num_fields($rs); print("<table><tr><th colspan=4>server_list</th></tr>"); echo(" "); print("<tr>"); for ($i=0;$i<$num;$i++){ print("<td><b>".mysql_field_name($rs,$i)."</b></td>"); } print("</tr>"); while($row=mysql_fetch_array($rs)){ echo(" "); print("<tr>"); for($j=0;$j<$num;$j++){ print("<td>".$row[$j]."</td>"); } print("</tr>"); } print("</table>"); mysql_free_result($rs); mysql_close($db); ?> </body> </html>
4.FTP後にパーミッションを755に変更
0 件のコメント:
コメントを投稿