如何通过php和HTML在mysql中只显示非零字段? [英] How to display only non zero fields in mysql through php and HTML?

查看:45
本文介绍了如何通过php和HTML在mysql中只显示非零字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上图是mysql数据库中数据的入口.

Above image is the entry of data in mysql database.

上图是我得到的输出,

但我只需要显示非零字段作为输出,这意味着仅从样本恢复"列到库qc"列.

But i need to display only non zero fields as the output that means from "sample revived" column to "library qc" column only.

php 脚本是

<?php

$userinput1 = $_POST['soid'];

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "status";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_errno) {
printf("Connect failed: %s\n", $conn->connect_error);
exit();
}

$result = mysqli_query($conn, "SELECT * FROM $dbname.statusinfo WHERE soid = '$userinput1'  ") or die(mysqli_error
    ($conn));
echo "<p><font size= 4>SO_NUMBER:$userinput1";

echo "<table border='1'>
<tr>
<style>
th{
color: blue;
}

td{
color: black;
}
</style>

<th>Sample Recived</th>
<th>Mol-Bio Extraction</th>
<th>Extraction QC</th>
<th>Library Prep</th>
<th>Library QC</th>
<th>Sequencing</th>
<th>Data Check</th>
<th>RE Sequencing</th>
<th>QC Check</th>
<th>Analysis Started</th>
<th>Analysis Completed</th>
<th>Report</th>
<th>Outbound</th>
 </tr>";
while($row = mysqli_fetch_assoc($result))
   {
echo "<tr>";
   echo "<br />";
echo "Department:".$row['dept'] ;
echo "<td>" . $row['samplerecived'] . "</td>";
   echo "<td>" . $row['molbioextraction'] . "</td>";
echo "<td>" . $row['molbioextractionqc'] . "</td>";
echo "<td>" . $row['libraryprep'] . "</td>";
   echo "<td>" . $row['libraryqc'] . "</td>";
echo "<td>" . $row['sequencing'] . "</td>";
echo "<td>" . $row['datacheck'] . "</td>";
   echo "<td>" . $row['resequencing'] . "</td>";
echo "<td>" . $row['qccheck'] . "</td>";
echo "<td>" . $row['analysisstarted'] . "</td>";
   echo "<td>" . $row['analysiscompleted'] . "</td>";
echo "<td>" . $row['report'] . "</td>";
echo "<td>" . $row['outbound'] . "</td>";
echo "</tr>";
}
echo "</table>";  
?>   

推荐答案

在你的 while 循环中像这样对每个字段使用(像这样对所有字段使用):

inside your while loop use for each field like this (use like this for all fields):

while($row = mysqli_fetch_assoc($result))
   {

if($row['samplerecived']=="0000-00-00") $row['samplerecived']="";

echo "<tr>";
   echo "<br />";
echo "Department:".$row['dept'] ;
echo "<td>" . $row['samplerecived'] . "</td>";
   echo "<td>" . $row['molbioextraction'] . "</td>";
echo "<td>" . $row['molbioextractionqc'] . "</td>";
echo "<td>" . $row['libraryprep'] . "</td>";
   echo "<td>" . $row['libraryqc'] . "</td>";
echo "<td>" . $row['sequencing'] . "</td>";
echo "<td>" . $row['datacheck'] . "</td>";
   echo "<td>" . $row['resequencing'] . "</td>";
echo "<td>" . $row['qccheck'] . "</td>";
echo "<td>" . $row['analysisstarted'] . "</td>";
   echo "<td>" . $row['analysiscompleted'] . "</td>";
echo "<td>" . $row['report'] . "</td>";
echo "<td>" . $row['outbound'] . "</td>";
echo "</tr>";
}

这篇关于如何通过php和HTML在mysql中只显示非零字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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