Coba ini:
$result = mysqli_query($conn, "SELECT * FROM $dbname.statusinfo WHERE soid = '$userinput1' AND date_column <> '0000-00-00' ") or die(mysqli_error($conn));
Meskipun, dengan mysql Anda bahkan dapat melakukan ini:
$result = mysqli_query($conn, "SELECT * FROM $dbname.statusinfo WHERE soid = '$userinput1' AND date_column > '0000-00-00' ") or die(mysqli_error($conn));
Semoga membantu
EDIT
Saya dapat melihat apa yang Anda inginkan sekarang setelah Anda mengubah pertanyaan :) Sayangnya saya tidak tahu cara untuk apa yang Anda inginkan menggunakan SQL (seseorang mungkin).
Anda mengeluarkan judul kolom sehingga tidak mengeluarkan kolom tertentu akan menyebabkannya muncul di kolom yang salah sehingga Anda tidak perlu mengeluarkan apa pun di mana waktunya adalah 0000-00-00
Ini adalah bagaimana saya akan melakukannya di PHP. (dan jika saya melewatkan poin Anda lagi, saya mungkin akan menembak diri saya sendiri :))
<?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>
EDIT
Judul tabel tidak dikeluarkan jika bidang berisi 0000-00-00. Ini hanya bergantung pada satu elemen yang dikeluarkan pada satu waktu.
<?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>