I have 40 columns rows that i want to fill in "No Data" automatically. This my code:
if (isset($people)) {
$sql = "SELECT * FROM people WHERE Name = '$people' LIMIT 0,1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "
<table>
<tr><th>Name</th><td>". $row["Name"]."</td></tr>
<tr><th>Full Name</th><td>". $row["FullName"]."</td></tr>
<tr><th>Address</th><td>". $row["Address"]."</td></tr>
<tr><th>BirthDate</th><td>". $row["BirthDate"]."</td></tr>
<tr><th>Spouses</th><td>". $row["Spouses"]."</td></tr>
etc..
</table>
I could use if statements in each tr like this, but i don't like it, there should be shorter way. if($row['Spouses'] == ""){ echo "";} else{ echo $row["Spouses"];}
source https://stackoverflow.com/questions/69319931/how-to-assign-no-data-in-all-rows-when-the-values-are-nulls
Comments
Post a Comment