Symfony 如果还有隐藏div

Symfony 如果还有隐藏div,symfony,if-statement,doctrine,symfony-forms,symfony-2.1,Symfony,If Statement,Doctrine,Symfony Forms,Symfony 2.1,我在隐藏div时遇到问题。。。。。如果query为NULL,则不会显示div,但如果query不是NULL则会显示div 这是我的密码: 顾客合唱团 顺便说一句,我用的是symfony/学说 我认为您需要检查从fetchArray()返回的数组是否没有任何元素。。你能详细说明你的答案吗?非常感谢。eMemberships可能是一个空数组而不是空数组。是的,你说得有道理,伙计。。。如果它是空的,你的意思是说它也有一个元素?该数组没有返回值。。。我该怎么办?它让我头痛。。。。我只想在没有数据的情

我在隐藏
div
时遇到问题。。。。。如果
query
NULL
,则不会显示
div
,但如果
query
不是
NULL
则会显示
div

这是我的密码:


顾客合唱团

顺便说一句,我用的是symfony/学说

我认为您需要检查从fetchArray()返回的数组是否没有任何元素。。你能详细说明你的答案吗?非常感谢。eMemberships可能是一个空数组而不是空数组。是的,你说得有道理,伙计。。。如果它是空的,你的意思是说它也有一个元素?该数组没有返回值。。。我该怎么办?它让我头痛。。。。我只想在没有数据的情况下删除该跳转..使用if(count($eMemberships)==0)
 <?php
     $q = Doctrine_Query::create()
         ->select('m.MemberNo')
         ->from('Membership m')
         ->where('m.EntityID = ?',$entity->getId());
         $eMemberships = $q->fetchArray();
         $ctr == 0;

       if(!$eMemberships){
       }
       else{

  ?>
<div class="largeform" style="height: 370px; width: 906px; background-color: #FFFFFF;">
    <!--h2>Customer Cards Associated to Entity <?php echo $entity->getFirstName()." ".$entity->getLastName() ?></h2-->
    <h2>Customer Chorva <?php echo $gfUtil->transLang($_SESSION["lang"], 'CustomerassocEntity')?> <?php echo $entity->getFirstName()." ".$entity->getLastName() ?></h2>
    <table cellpadding="2" cellspacing="0">
        <thead>
            <tr>
                <th style="color: gray"><?php echo $gfUtil->transLang($_SESSION["lang"], 'membershipid')?></th>
                <th style="color: gray"><?php echo $gfUtil->transLang($_SESSION["lang"], 'cardno')?></th>
                <th style="color: gray"><?php echo $gfUtil->transLang($_SESSION["lang"], 'carduid')?></th>
                <th style="color: gray"><?php echo $gfUtil->transLang($_SESSION["lang"], 'type')?></th>
                <th style="color: gray"><?php echo $gfUtil->transLang($_SESSION["lang"], 'membershipid')?></th>
                <th style="color: gray"><?php echo $gfUtil->transLang($_SESSION["lang"], 'rebatepercent')?></th>
                <th style="color: gray"><?php echo $gfUtil->transLang($_SESSION["lang"], 'activationdate')?></th>
            </tr>
        </thead>

        <tbody>

        <?php foreach($eMemberships as $eMembership):?>
        <?php
            $q = Doctrine_Query::create()
                ->select('c.id as cID, c.CardNo as cNo, c.CardUID as cUID, c.Type as cType, c.Status as cStatus, c.MembershipID as cMID, c.RebatePercent as cPercent, c.ActivationDate as cDate')
                ->from('Card c')
                ->where('c.MemberNo = ? AND c.Type = 4',$eMembership["id"]);
                $eCards = $q->fetchArray();
        ?>
        <?php foreach($eCards as $ecard): ?>
            <tr>
                <td><?php echo $eMembership["id"] ?></td>
                <td><?php echo $ecard["cNo"] ?></td>
                <td><?php echo $ecard["cUID"] ?></td>
                <td><?php echo $ecard["cType"] ?></td>
                <td><?php echo $ecard["cMID"] ?></td>
                <td><?php echo $ecard["cPercent"] ?></td>
                <td><?php echo $ecard["cDate"] ?></td>
                <!--?php $ctr++; ?-->
            </tr>
        <?php endforeach ?>
        <?php endforeach ?>
        <!--?php if($ctr==0): ?-->
         <!--tr><td colspan="7"><?php  echo "No Record(s) found!"; ?></td></tr-->
        <!--?php endif ?-->
        </tbody>
    </table>
</div>
<?php
    }
?>