将mysql输出除以1000并显示具有特定输出的图像 [英] Divide mysql output by 1000 and show image with spicific output

查看:565
本文介绍了将mysql输出除以1000并显示具有特定输出的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试两件我不能上班的东西。



首先,我试图划分$ dt(纪元时间13个字符)来划分由1000表示正确的日期和时间,因为它以毫秒为单位保存在MySQL数据库中。我尝试在PHP中的不同位置用/ 1000划分它,在MySQL查询中用不同的例子从互联网上划分它,但是我尝试了一切我得到了一个不同的错误。



其次,我希望BackupState的输出是一个图像。例如,$ row ['BackupState']显示STATE_SUCCESS,STATE_SUCCCES_WITH_WARNINGS,STATE_BUSY或STATE_NOT_COMPLETED。对于每个州,我想展示不同的形象。



I am trying 2 different things that I don`t get to work.

First, I am trying divide $dt (epoch time 13 characters) to divide by 1000 so it shows the correct date and time since it is saved in the MySQL database in miliseconds. I tried to divide it with /1000 on different places in the PHP, and in the MySQL query with different examples from the internet, but with everything I try I get a different error.

Second, I want the output of BackupState to be an image. For example, $row['BackupState'] shows STATE_SUCCESS, STATE_SUCCCES_WITH_WARNINGS, STATE_BUSY or STATE_NOT_COMPLETED. For every state I would like to show a different image.

<?php 
$conn = new mysqli('host', 'user', '', 'database');
if ($conn->connect_error) {
	die("Connection error: " . $conn->connect_error);
}

$result = $conn->query("SELECT * FROM backupstate_tbl ORDER BY BackupTime DESC LIMIT 20");
if ($result->num_rows > 0) {
  // output the opening table tag only once before the loop
  echo '<table class="table" align="center">';
  echo "<tr><th>State</th><th>Name</th><th>Description:</th><th>Gestart:</th></tr>";
  while ($row = $result->fetch_assoc()) {
    			$epoch = $row['StartTime']; 	//Start Time of backup
    			$dt = new DateTime("@$epoch"); 				//Output date has to be divided by 1000
    			
    echo "<tr><td>"; 
    echo $row['BackupState'];
    echo "</td><td>";
	echo $row['ClientName'];
    echo "</td><td>";     
    echo $row['BackupTime'];
    echo "</td><td>";    
    echo $dt->format('Y-m-d H:i:s');
    echo "</td></tr>";
}
  // output the closing table tag only once at the end of loop
  echo "</table>";
}
?>





< b>我尝试了什么:



我试图通过互联网上的不同示例完成此操作,但我尝试的所有内容都会出错。



What I have tried:

I tried to complete this with different examples from the internet, but get an error with everything I try.

推荐答案

dt(纪元时间13个字符)除以1000,因此它显示正确的日期和时间,因为它以毫秒为单位保存在MySQL数据库中。我尝试在PHP中的不同位置用/ 1000划分它,在MySQL查询中用不同的例子从互联网上划分它,但是我尝试了一切我得到了一个不同的错误。



其次,我希望BackupState的输出是一个图像。例如,
dt (epoch time 13 characters) to divide by 1000 so it shows the correct date and time since it is saved in the MySQL database in miliseconds. I tried to divide it with /1000 on different places in the PHP, and in the MySQL query with different examples from the internet, but with everything I try I get a different error.

Second, I want the output of BackupState to be an image. For example,


row ['BackupState']显示STATE_SUCCESS,STATE_SUCCCES_WITH_WARNINGS,STATE_BUSY或STATE_NOT_COMPLETED。对于每个州,我想展示不同的形象。



row['BackupState'] shows STATE_SUCCESS, STATE_SUCCCES_WITH_WARNINGS, STATE_BUSY or STATE_NOT_COMPLETED. For every state I would like to show a different image.

<?php


conn = new mysqli(' < span class =code-string> host',' user'' '' 数据库);
if
conn = new mysqli('host', 'user', '', 'database'); if (


这篇关于将mysql输出除以1000并显示具有特定输出的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆