0

您好,我正在尝试更新此奖学金申请框。但是,当年份更改为 2013 年时,它只显示 2013 年的奖学金申请者信息。我希望它显示 2012 年的信息。我试着弄乱日期,但我似乎无法弄清楚。任何帮助将不胜感激!

    <?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'; }
4

1 回答 1

1

删除限制年份的 WHERE 子句。使用 ORDER BY 按年份降序排序。

$sql = 'select * from sApplication 
    where studentID = "'.$database->iPrep($_SESSION['ID']).
    '" ORDER BY appYear DESC LIMIT 1';
于 2013-02-07T16:44:33.340 回答