これを試してください:
$result = mysqli_query($conn, "SELECT * FROM $dbname.statusinfo WHERE soid = '$userinput1' AND date_column <> '0000-00-00' ") or die(mysqli_error($conn));
ただし、mysqlを使用すると、これを実行できる場合もあります:
$result = mysqli_query($conn, "SELECT * FROM $dbname.statusinfo WHERE soid = '$userinput1' AND date_column > '0000-00-00' ") or die(mysqli_error($conn));
これがお役に立てば幸いです
編集
質問を修正したので、あなたが何を望んでいるかがわかります:)残念ながら、SQLを使用してあなたが望むものへの道を知りません(誰かがそうするかもしれません)。
列見出しを出力しているため、特定の列を出力しないと、間違った列に表示されるため、時刻が0000-00-00の場合は何も出力する必要がありません
これは私が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));
$arrayHeadings = array(
"dept" => "Department",
"samplerecived" => "Sample Recived",
"molbioextraction" => "Mol-Bio Extraction",
"molbioextractionqc" => "Extraction QC",
"libraryprep" => "Library Prep",
"libraryqc" => "Library QC",
"sequencing" => "Sequencing",
"datacheck" => "Data Check",
"resequencing" => "RE Sequencing",
"qccheck" => "QC Check",
"analysisstarted" => "Analysis Started",
"analysiscompleted" => "Analysis Completed",
"report" => "Report",
"outbound" => "Outbound",
);
?>
<style>
th{
color: blue;
}
td{
color: black;
}
</style>
<table border='1'>
<tr>
<?php foreach($arrayHeadings as $key => $name): ?>
<th><?= $name; ?></th>
<?php endforeach; ?>
</tr>
<tr>
<?php while($row = mysqli_fetch_assoc($result)): ?>
<?php foreach($arrayHeadings as $key => $name): ?>
<?php if($row[$key] != "0000-00-00"): ?>
<td><?= $row[$key]; ?></td>
<?php else: ?>
<td></td>
<?php endif; ?>
<?php endforeach; ?>
<?php endwhile; ?>
</tr>
</table>
編集
フィールドに0000-00-00が含まれている場合、テーブルの見出しは出力されません。これは、一度に1つの要素のみが出力されることに依存しています。
<?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));
$arrayHeadings = array(
"dept" => "Department",
"samplerecived" => "Sample Recived",
"molbioextraction" => "Mol-Bio Extraction",
"molbioextractionqc" => "Extraction QC",
"libraryprep" => "Library Prep",
"libraryqc" => "Library QC",
"sequencing" => "Sequencing",
"datacheck" => "Data Check",
"resequencing" => "RE Sequencing",
"qccheck" => "QC Check",
"analysisstarted" => "Analysis Started",
"analysiscompleted" => "Analysis Completed",
"report" => "Report",
"outbound" => "Outbound",
);
?>
<style>
th{
color: blue;
}
td{
color: black;
}
</style>
<table border='1'>
<tr>
<?php foreach($arrayHeadings as $key => $name): ?>
<?php if($row[$key] != "0000-00-00"): ?>
<th><?= $name; ?></th>
<?php endif; ?>
<?php endforeach; ?>
</tr>
<tr>
<?php while($row = mysqli_fetch_assoc($result)): ?>
<?php foreach($arrayHeadings as $key => $name): ?>
<?php if($row[$key] != "0000-00-00"): ?>
<td><?= $row[$key]; ?></td>
<?php endif; ?>
<?php endforeach; ?>
<?php endwhile; ?>
</tr>
</table>