Colo
Colo

Reputation: 87

Deactivating links in PHP

The below code has a link to apply for a job only when a deadline is not met.How can I make the link deactivate after the deadline for application has passed,or just change the link label from 'apply' to 'closed'?I will appreciate your help.

while($row = mysqli_fetch_array($query))
  {

    $ref=$row['id'];

  echo "<tr id=".$ref.">";
   echo "<td >" .$row['refNo'] . "</td>";
   echo "<td >" . $row['title'] . "</td>";
   echo "<td >" . $row['positions'] . "</td>";
   echo "<td>" . $row['typeofContract']."</td>";
   echo "<td>" . $row['deadline'] . "</td>";
   echo "<td>" .$row['dept']."</td>";
   $det= $row['details'];

   echo "<td style='width:100px' >" ."<a href='../../admin/admin/jobdetails/".$det."' target='_blank'>Job details</a>" . "</td>";

   echo "<td>".'<a href="apply.php?deptid='.$ref.'" style="color:blue" >Apply</a>'."</td>";

  echo "</tr>";
  }

Upvotes: 0

Views: 45

Answers (1)

messerbill
messerbill

Reputation: 5629

 if($row['deadline'] >= time()) echo "<td>".'<a href="apply.php?deptid='.$ref.'" style="color:blue" >Apply</a>'."</td>";

if your $row['deadline'] is a timestamp, this echo would only be fired if the timestamp is lower than the actual time. of course you can return any html in that case, for example:

 if($row['deadline'] >= time()) echo "<td>".'<a href="#" style="color:blue" >DEADLINE REACHED</a>'."</td>";

hope it helps

edit:

http://www.w3schools.com/php/func_date_time.asp

Upvotes: 1

Related Questions