php if statment unknown feild value hide

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

php if statment unknown feild value hide

Post by jonnyfortis »

i have a table that i need to show only if contents is in my DB, i can make it work if i know the value of the feild but this feild will be peoples names so i just want the table to show if the feild is populated

Code: Select all

//variable for showing tenants
 
$ten_info1 = $row_rsTenant['tenTen1FirstN'];
 
<?php if ($ten_info1 == 'bob'):?>
        <td bgcolor="#C7E538">Tenant 1 name</td>
        <td><?php echo $row_rsTenant['tenTen1FirstN']; ?> <?php echo $row_rsTenant['tenTen1MiddN']; ?> <?php echo $row_rsTenant['tenTen1SurnN']; ?></td>
        <td bgcolor="#C7E538">Share of rent</td>
        <td><?php echo $row_rsTenant['tenTen1Share']; ?></td>
        <td bgcolor="#C7E538">To be paid by</td>
        <td><?php echo $row_rsTenant['tenTen1TbePaid']; ?></td>
                    <? endif; ?>


so i need to know what to replace bob with so if any name is inserted into the feild the table will show
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: php if statment unknown feild value hide

Post by jonnyfortis »

sorted it

<?php if (!empty($row_rsTenant['tenTen2FirstN'])):?>
Post Reply