|
 |
|
กรณีนี้หากจะดึงค่าใน mysql ทำไงครับ ? จาก code ด้านบน อยากจะสร้างฐานข้อมูลเพื่อเก็บ ip เช่น 192.168.9.1 แล้วนำค่านั้นมาเช็ค |
|
 |
|
|
 |
 |
|
<?php
$ips_array=array("[ Computer 2 ] Server Freebsd 7.x [ kbschool ]:192.168.9.1"," [ computer 2 ] Ubuntu 9.04 [ kbschool ]
:192.168.9.9");
function ping($PC,$ip){
$cmd=shell_exec("ping -c 1 -w 1 $ip");
$dati_mount=explode(",",$cmd);
if (eregi ("0", $dati_mount[1], $out)) {$connesso="<img src=\"off.gif\">";}
if (eregi ("1", $dati_mount[1], $out)) {$connesso="<img src=\"on.gif\">";}
$esito="$connesso <font size='1' face='MS Sans Serif' color='00000'> $PC</font><br>";
return $esito;
}
while(list($k,$v)=each($ips_array)){
$dati_ip=explode(":",$v);
$esito=ping($dati_ip[0],$dati_ip[1]);
echo $esito;
}
?>
จากโค๊ดด้านบน แสดงผลดังนี้ http://rachun.no-ip.org/acc.php
จาก code ด้านบน อยากจะสร้างฐานข้อมูลเพื่อเก็บ ip เช่น 192.168.9.1
แล้วนำค่านั้นมาเช็ค ให้แสดงผล ดังตัวอย่าง
จาก code หากเราจะเพิ่ม ip อื่นเราต้องมาพิมพ์ที่ .php
อยากจะเพิ่มลงฐานข้อมูล มากกว่าครับ แนะนำหน่อยครับ มือใหม่ php จริงๆครับ ขอบคุณครับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-06-15 12:02:52 |
By :
rachunsun |
View :
1117 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวนี้เป็น ip เครื่องอื่นใช่ไหม
ถ้าเป็นเครื่องอื่นก้อให้ทำการเก็บค่า ip จากเครื่องอื่นก่อน ไว้ที่ table1 แล้วค่อยดึงมาใช้อีกทำจะดีไหม
|
 |
 |
 |
 |
Date :
2009-06-15 12:21:01 |
By :
krataiss |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$_SERVER['REMOTE_ADDR' ]; ใช้ตัวเนี่ยเก็บ ip เครื่องอื่น
|
 |
 |
 |
 |
Date :
2009-06-15 12:23:44 |
By :
krataiss |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เก็บแล้วดึงมาพอจะแนะนำการเขียน code ให้หน่อยได้มะครับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2009-06-15 13:50:35 |
By :
rachunsun |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|