我的HTML文件包含以下CSS:
<style>
#circleRed {
background: #ff0000;
width: 15px;
height: 15px;
border-radius: 50%;
}
#circleGreen {
background: #00ff00;
width: 15px;
height: 15px;
border-radius: 50px;
}
</style>
<div id="circleRed"></div>
<div id="circleGreen"></div>
在同一个HTML文件中,我有一个PHP脚本:
<?php
function ReturnError($res)
{
switch ($res)
{
case "0":
return " No errors";
case "-1":
return " Video not found. This could be due to incorrect video format.";
case "-2":
return " Video file could not be opened.";
case "-3":
return "il_client failed to initiate. Might be due to resource issue, e.g. not enough RAM space.";
case "-4":
return "OMX player failed to initiate. Please try rebooting the PI, or replace the PI.";
}
}
$command = "ssh -p 97 -i /var/www/html/test1.rsa pi@192.168.xxx.xxx tail -1 /var/log/playlog.csv";
$output = exec($command);
if($idx = strripos($output,','))//Get the last index of ',' in the output string
{
$ErrorCode = substr($output,$idx + 1,(strlen($output) - $idx) - 1);//using the found index, get the error code using substring
$Playlist = substr($output, 0, $idx + 1);//Get the rest of the output string, minus the error code
echo "Test: <p></p>Currently Playing: ".$Playlist.ReturnError($ErrorCode);//The ReturnError function just replaces the error code with a custom error
}
?>
哪个输出:
Test:
Currently Playing: 2018-03-27 09:41:36,NM_Test.h264, No errors
我怎样才能将输出回显到HTML表格中,如下所示:
+--------+----------+-----------+-------+-------------+
| Status | Name | Date/time | Video | Error Status|
+--------+----------+-----------+-------+-------------+
取决于执行哪个switch语句:
类似于:
+-------------+--------+-------------------+-------------+-------------+
| Status | Name | Date/time | Video | Error Status|
+-------------+------------------------------------------+-------------+
|#circleGreen | Test |2018-03-27 09:41:36| NM_Test.h264| No Errors |
+-------------+--------+-------------------+-------------+-------------+
更新
根据用户的反馈,我试图通过以下方式使用爆炸:
$array = explode(',',$output);
echo $array[0];
echo $array[1];
echo $array[2];
然后我可以使用HTML表格标签将每个数组输出为表格,但是使用这种方法我无法弄清楚如何使用if语句实现我目前正在做的事情?
答案 0 :(得分:0)
你可以像这样添加你的文件php
<table border="1">
<tr>
<th>Nom etudiant</th>
<th>Prenom</th>
<th>CIN</th>
<th>Note tp</th>
<th>Note ds</th>
<th>Note exam</th>
</tr>
<?php
$sql5 = "select * from `etudiant` , `etudier` where (`id_section`='$id_section' and `etudier`.`id_etudiant`=`etudiant`.`cin` and `etudier`.`id_matiere`='$id_matiere');";
if($req2 = mysql_query($sql5)){
while($data2 = mysql_fetch_array($req2)){
?>
<tr>
<td><?php echo $data2['nom'] ?></td>
<td><?php echo $data2['prenom'] ?></td>
<td><?php echo $data2['cin'] ?></td>
<td><?php echo $data2['note_tp'] ?></td>
<td><?php echo $data2['note_ds'] ?></td>
<td><?php echo $data2['note_exam'] ?></td>
<?php
$link="ajoute_note_etudiant.php?id_etudiant=".$data2['cin']."&id_matiere=".$id_matiere;
?>
<td><a href="<?php echo $link ?>">Modifer</a></td>
<?php
}}else{
echo "da5let";
}?>
</tr>
</table>
&#13;