Page 1 of 1

php if statment unknown feild value hide

Posted: Thu Mar 28, 2013 6:19 am
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

Re: php if statment unknown feild value hide

Posted: Thu Mar 28, 2013 9:04 am
by jonnyfortis
sorted it

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