简体   繁体   English

从表中提取去年的数据

[英]Pulling last years data from a table

Hello I'm trying to update this scholarship application box. 您好,我正在尝试更新此奖学金申请箱。 However when the year changed to 2013 it only displays scholarship applicant info from 2013. I'd like it to display info from 2012. I tried messing around with the date but I cant seem to figure it out. 但是,当年份更改为2013时,它仅显示2013年的奖学金申请者信息。我希望它显示2012年的信息。我尝试弄乱日期,但似乎无法弄清楚。 Any help would be greatly appreciated! 任何帮助将不胜感激!

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

Remove the WHERE clause that limits the year. 删除限制年份的WHERE子句。 Use ORDER BY to sort by year, descending. 使用ORDER BY按年份(降序)排序。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM