所以我基本上是 php/mysql 的初学者,这是当前的代码:
$sql = "SELECT id, userid, date, rig, hash, miner_hashes, temp, fanrpm, rack_loc,ip, uptime, gpus, driver, cpu_temp, miner, miner_version, mem, powertune, fanpercent, voltage, miner_secs, version FROM hash WHERE rig='bbf3ec' ORDER BY ID DESC LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>"
. $row["version"]. "</td><td>"
. $row["driver"] . "</td><td>"
. $row["gpus"] . "/8</td><td>"
. $row["miner"] . "</td><td>"
. $row["miner_version"] . "</td><td>"
. $row["miner_secs"] . "</td><td>"
. $row["rig"] . "</td><td>"
. $row["rack_loc"] . "</td><td>"
. $row["ip"] . "</td><td>"
. $row["cpu_temp"] . "c</td><td>"
. $row["hash"] . "</td><td>"
. $row["miner_hashes"] . "</td><td>"
. $row["temp"] . "</td><td>"
. $row["voltage"] . "</td><td>"
. $row["fanpercent"] . "</td><td>"
. $row["powertune"] . "</td><td>"
. $row["mem"]. "</td></tr>";
}
echo "";
} else { echo "0 results"; }
目前我只是从数据库中将 miner_secs 值打印为 INT,但我希望它首先转换为小时,然后将其插入到一行中,知道如何做到这一点吗? 我再次成为这方面的初学者,每个解释都受到高度重视!
最佳答案
即使它是一个字符串,您仍然可以对minor_secs进行计算。
. round(($row['miner_secs']/60)/60,2) . "</td><td>"
我将输出除以 60,然后再除以 60。然后将其四舍五入以避免疯狂的精度。
关于php - 从mysql读取秒并转换为小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58923126/