<?php
$mysqli_link = mysqli_connect("localhost", "root", "");
mysqli_select_db("fincrop") or die("Could not select database");
?>

<?php
if( empty($_GET['hpl']) )
{
?>
<html>
<head><title>List of Reminders</title></head>
<body>
<table width="90%" border="0" align="center">
<tr>
<td colspan='3'><a href='#'>Add new Reminder</a></td>
</tr>
<?php
$result = mysqli_query($conn,  "SELECT * FROM duedate" );
$nr = mysqli_num_rows( $result );
if(empty($nr))
{
echo("
<tr>
<td colspan='3'>No Reminders setup</td>
</tr>
");
}
while( $row = mysqli_fetch_array( $result ))
{
$reminder_name = $row["vno"];
$reminder_date = $row["due1"]."-".$row["due2"]."-".$row["due3"];
$reminder_id = $row["hpl"];
echo("
<tr>
<td width='60%'>$reminder_name</td>
<td width='30%'>$reminder_date</td>
<td width='10%'><a href='reminder_list.php?reminder_id=$reminder_id'>delete</a></td>
</tr>
");
}
mysqli_free_result( $result );
?>
</table>
</body>
</html>
<?php
}
else
{
mysqli_query($conn,  "DELETE FROM reminder_events where mfin='$mfin' &&  reminder_id='".addslashes($_GET['reminder_id'])."'" );
// Let's go back to the Reminder List page
Header("Refresh: 1;url=reminder_list.php");
echo <<< _HTML_END_
Reminder Deleted, redirecting...
_HTML_END_;
}
?>
