2012-09-11 89 views
0

我有一個問題.....所有我wan't做,如果queryNULL那麼div將無法​​顯示,但如果query不是NULLdiv將顯示。如果別人對隱藏<code>div</code>隱藏的div

這裏是我的代碼:

<?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 
    } 
?> 

由我使用的symfony /學說的方式..

回答

0

我認爲你需要檢查陣列從fetchArray(返回)沒有任何元素而不是

+0

抱歉,夥計,我不能讓你..你能否詳細說明你的答案非常感謝。 – Lian

+0

它可能eMemberships將是一個空數組,而不是空 – MichaelT

+0

是你有一個點有豬頭...所以如果是空的,你的意思是說它也有一個元素? 該數組沒有返回值...我該怎麼辦?它讓我頭疼....我只是想,如果沒有數據刪除該潛水.. – Lian