php - Pulling last years data from a table -
hello i'm trying update scholarship application box. when year changed 2013 displays scholarship applicant info 2013. i'd display info 2012. tried messing around date cant seem figure out. help appreciated!
<?php $appyear = date("y").'-'.(date("y")+1); $sql = 'select * sapplication studentid = "'.$database->iprep($_session['id']).'" , 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"> </td> </tr> <tr> <td><strong>references</strong></td> <td align="right"> </td> </tr> <tr> <td><strong>decision</strong></td> <td> </td> </tr> <tr> <td colspan="2"><hr /></td> </tr> <tr> <td><strong>scholarship 2012-2013</strong></td> <td> </td> </tr> <tr> <td><strong>decision</strong></td> <td> </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"> </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 * reference appid = '".$app->id."'");?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php foreach($refs $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 clause limits year. utilize order sort year, descending.
$sql = 'select * sapplication studentid = "'.$database->iprep($_session['id']). '" order appyear desc limit 1';
php sql
No comments:
Post a Comment