I'm trying to make a library booking system so when user borrows a book, they will have a due date set 7 days after the issue date (set as CURRENT_TIMESTAMP). However, is there a way for me to just use the CURRENT_TIMESTAMP + 7 days in the php/html code? or do I need to add another table column to set the due date variable in the database?
I have tried to change a variable (fine) in the database which is not needed in my database with the due date. However, this messes up the whole thing which the data wont show.
So currently, I'm trying to add 7 days to the IssueDate variable via DATE_ADD function. However, this won't allow the code to show.
<tr>
<th>#</th>
<th>Book Name</th>
<th>ISBN </th>
<th>Issued Date</th>
<th>Due Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$sid=$_SESSION['stdid'];
$sql="SELECT tblbooks.BookName,tblbooks.ISBNNumber,tblissuedbookdetails.IssuesDate,tblissuedbookdetails.ReturnDate,tblissuedbookdetails.id as rid,tblissuedbookdetails.fine from tblissuedbookdetails join tblstudents on tblstudents.StudentId=tblissuedbookdetails.StudentId join tblbooks on tblbooks.id=tblissuedbookdetails.BookId where tblstudents.StudentId=:sid order by tblissuedbookdetails.id desc";
$query = $dbh -> prepare($sql);
$query-> bindParam(':sid', $sid, PDO::PARAM_STR);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{ ?>
<tr class="odd gradeX">
<td class="center"><?php echo htmlentities($cnt);?></td>
<td class="center"><?php echo htmlentities($result->BookName);?></td>
<td class="center"><?php echo htmlentities($result->ISBNNumber);?></td>
<td class="center"><?php echo htmlentities($result->IssuesDate);?></td>
<td class="center"><?php if($result->ReturnDate=="")
{?>
<span style="color:red">
<?php echo htmlentities("Not Return Yet"); ?>
</span>
<?php } else {
echo htmlentities($result->SELECT DATE_ADD(d,7,IssuesDate));
}
?></td>
<td class="center">
<a href="test-return.php?rid=<?php echo htmlentities($result->rid);?>">
<button class="btn btn-primary"><i class="fa fa-edit "></i>Extend</button>
</td>
</tr>
<?php $cnt=$cnt+1;}} ?>
</tbody>
Any "working codes" will not show the results in the "due date" table column and those that are not will just said there's unexpected variable, symbols, etc.