Page 1 of 1

Can someone tell me if this is even possible?

Posted: Mon Mar 08, 2010 10:40 am
by moomin52
Hi - I have a table in a php page where these are the first two rows:

<tr>
<td><span class="style2">Artist</span></td>
</tr>
<tr>
<td><span class="style8">
<?php if ($totalRows_rsRecRes > 0) { // Show if recordset not empty ?>
<?php echo $row_rsRecordings['recordingartistName']; ?>
<?php } // Show if recordset not empty ?></span></td>
</tr>

basically what I want to be able to do is to hide the header (Artist) if the database field that should populate the second row (recordingartistName) is empty. Is it possible to do this in PHP and if so, could some good samaritan show me using the above code how I'd go about doing it, please? I'd be forever grateful. Thanks.

Re: Can someone tell me if this is even possible?

Posted: Mon Mar 08, 2010 10:52 am
by AbraCadaver
Just move the if statement up before the Artist row:

Code: Select all

<?php if ($totalRows_rsRecRes > 0) { // Show if recordset not empty
?>
<tr>
<td><span class="style2">Artist</span></td>
</tr>
<tr>
<td><span class="style8">
<?php echo $row_rsRecordings['recordingartistName'];?>
</span></td>
</tr>
<?php } // Show if recordset not empty
?>

Re: Can someone tell me if this is even possible?

Posted: Mon Mar 08, 2010 11:28 am
by moomin52
Thanks for the suggestion, but that didn't do it - the header still displays, and there's a blank space where the field detail should go...

Re: Can someone tell me if this is even possible?

Posted: Mon Mar 08, 2010 12:21 pm
by social_experiment
Try printing the table only if $totalRows_rsRecRes > 0 :

Code: Select all

<?php if ($totalRows_rsRecRes > 0) {
 echo '<table>';
 // rest of your code
 echo '</table>';
}
else {
 // something to indicate no record
} ?>

Re: Can someone tell me if this is even possible?

Posted: Mon Mar 08, 2010 1:31 pm
by moomin52
Thanks, but I got a parse error when I tried that...

Re: Can someone tell me if this is even possible?

Posted: Mon Mar 08, 2010 4:34 pm
by social_experiment
That doesn't mean the idea is incorrect, it means there is an error with the code. Please paste the problematic code.