TS3状态 - 添加TD标签

时间:2016-08-28 00:21:05

标签: php html status

我不知道该怎么做因为我不太了解PHP,但我想做这件事,我有这个HTML代码:

<td class="servers" id="online">EXAMPLE ONLINE / OFFLINE FROM PHP</td> 

我想放入&lt; td&gt;标记服务器状态ONLINE / OFFLINE我将从我的PHP代码中获得:

<?php
//Load Framework
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

try {
//Connect
   $ts3 = TeamSpeak3::factory("serverquery://serveradmin:querypassword@ts3.domain:10011/?server_port=9987");

//Server Status
echo "ONLINE";
}
catch(Exception $e) {
//Errors (No connection)
echo "OFFLINE";
}

?>

怎么做,请帮忙。

1 个答案:

答案 0 :(得分:0)

<?php
//Load Framework
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

try {
//Connect
   $ts3 = TeamSpeak3::factory("serverquery://serveradmin:querypassword@ts3.domain:10011/?server_port=9987");

//Server Status
$result = "ONLINE";
}
catch(Exception $e) {
//Errors (No connection)
$result = "OFFLINE";
}

echo "<td class='servers' id='$result'>$result</td>";
?>