I have created a database through PHPmyadmin and am pulling information from that database into my wordpress site. Currently, rows that have no data in them still show up. For example, if I do not enter a start_date, the heading "Start date" would still appear even though it has no value.
May I know how to re-write the code so as to hide the headings if there is no value? I would like this to be applicable to all headings ie. start_date, description etc.
Thank you.
<?php
$mysqli = NEW mysqli('localhost','surviboj_wp156','p365SJ@37)','surviboj_wp156');
require('/home/surviboj/public_html/wp-load.php');
$id = get_the_ID();
$resultSet = $mysqli->query("SELECT * FROM sweepstake_data WHERE item_id = $id");
if($resultSet->num_rows !=0){
while($rows = $resultSet->fetch_assoc())
{
$description = $rows['description'];
$links = $rows['links'];
$category = $rows['category'];
$eligibility = $rows['eligibility'];
$start_date = $rows['start_date'];
$end_date = $rows['end_date'];
$entry_frequency = $rows['entry_frequency'];
$prizes = $rows['prizes'];
$victory_prizes = $rows['victory_prizes'];
$additional_comments = $rows['additional_comments'];
echo "<p>Name: $description<br /> Link: <a href=$links>Click here</a> <br /> Category: $category<br /> Eligibility: $eligibility<br /> Start date:$start_date<br /> End date: $end_date<br /> Entry frequency: $entry_frequency<br /> Prizes: $prizes<br /> Victory prizes: $victory_prizes<br /> Additional comments: $additional_comments<br />";
}
}else {
echo "No results.";
}
?>