2013-02-07 3 views
0

Bonjour, J'essaie de mettre à jour cette boîte de demande de bourse. Cependant, lorsque l'année a changé en 2013, elle n'affiche que les informations sur les demandes de bourses d'études de 2013. Je voudrais que l'information soit affichée à partir de 2012. J'ai essayé de décoder la date, mais je n'arrive pas à la comprendre. Toute aide serait grandement appréciée!Tirer les données des dernières années à partir d'une table

<?php 
$appYear = date("Y").'-'.(date("Y")+1); 
$sql = 'select * from sApplication where studentID = "'.$database->iPrep($_SESSION['ID']).'" AND appYear = "'.$appYear.'" LIMIT 1'; 
$appID = Scholarship::iFindSQL($sql); 
$total = count($appID); 
if ($total > 0) 
    { 
     $app = array_shift($appID); 
    } 
    else 
     { 
      $app = 0; 
     } 
?> 
<li id="item-2"> 
    <div id="appStatus"> 
    <h3>Application Status</h3> 
    <blockquote> 
    <?php if ($app->submitted == ('0000-00-00') || !isset($app->submitted)) { ?> 

    <table style="border:1px solid #000;" width="100%" border="0" cellspacing="5" cellpadding="0"> 
    <tr> 
    <td width="50%"><strong>Scholarship<br /> 2013-2014</strong></td> 
    <td width="50" align="right"> <a style="font-size:16px;" href="welcome.php? app=Scholar">Apply Now</a></td> 
    </tr> 
    <tr> 
    <td><strong>Date Submitted</strong></td> 
    <td align="right">&nbsp;</td> 
    </tr> 
    <tr> 
    <td><strong>References</strong></td> 
    <td align="right">&nbsp;</td> 
    </tr> 
    <tr> 
    <td><strong>Decision</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td colspan="2"><hr /></td> 
    </tr> 
    <tr> 
    <td><strong>Scholarship 2012-2013</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <td><strong>Decision</strong></td> 
    <td>&nbsp;</td> 
    </tr> 
    </table> 



     <?php } else { ?> 
     <table style="border:1px solid #000;" width="100%" border="0" cellspacing="5" cellpadding="0"> 

     <tr> 
      <td width="90%"><strong>Scholarship 2013-2014</strong></td> 
      <td width="10%" align="right">&nbsp;</td> 
     </tr> 
     <tr> 
      <td><strong>Date Submitted</strong></td> 
      <td align="right"><?=dbOutDate($app->submitted)?></td> 
     </tr> 
     <tr> 
      <td><strong>References</strong> </td> 
      <td align="right"></td> 
     </tr> 

     <tr> 
     <td colspan="2"> 
     <?php 
     $refs = Reference::iFindSQL("Select * from reference where appID = '".$app->ID."'");?> 

     <table width="100%" border="0" cellspacing="0" cellpadding="0"> 

     <?php foreach($refs as $ref) { ?> 
     <tr> <td> <small><?php if($ref->rType == 'Academic Reference'){ echo 'Academic/Artistic/Professional'; } else { echo 'Community Service'; } ?></small></td> <td align="right"><?=$ref->status?></td></tr> 
     <?php } ?> 

     </table> 
     </td> 
     </tr> 
     <tr> 
      <td><strong>Decision</strong></td> 
      <td align="right"> 
     <?php 
       if ($app->complete == 'Approved') { echo '<a href="'.$_SERVER['PHP_SELF'].'?app=Bank&appID='.$app->ID.'">Approved</a>'; } 
       if ($app->complete == 'Declined') { echo '<a href="'.$_SERVER['PHP_SELF'].'?app=Declined&appID='.$app->ID.'">Declined</a>'; } 
       if ($app->complete == 'Pending') { echo 'Pending'; } 
       if ($app->complete == 'Incomplete') { echo 'Incomplete'; } 

Répondre

1

Supprimez la clause WHERE qui limite l'année. Utilisez ORDER BY pour trier par année, en descendant.

$sql = 'select * from sApplication 
    where studentID = "'.$database->iPrep($_SESSION['ID']). 
    '" ORDER BY appYear DESC LIMIT 1'; 
Questions connexes