Forum Moderators: coopster
<html>
<head>
<title>Open Pharmacy</title>
<style type="text/css">
table tr td { font: 12px Verdana, Arial, sans-serif;
text-align: center;
font-weight: bold;
}
table tr th { font-size: 12px;
text-align: center;
}
</style>
</head>
<body>
<?php
include 'library/config.php';
include 'library/opendb.php';
include 'library/paging_function.php';
$ExpLef = $_POST['EexpLef'];
// query the table
$result = mysql_query("SELECT count(*) FROM pharmacy");
$total = mysql_result($result, 0);
$news = mysql_query("SELECT * FROM pharmacy WHERE ExpLeft='ExpLef' ORDER BY id ASC LIMIT $start, $display");
echo "<table border='1'>";
echo "<tr><th>Id</th><th>Code</th><th>Name</th><th>ExpLeft</th></tr>";
while($row = mysql_fetch_assoc($news)) {
// Expiray Left in Months
$Exp = $row[Exp];
$expires=strtotime($Exp);
$rightnow=time();
$secondsleft=$expires-$rightnow;
$ExpLeft=round($secondsleft/2592000);
echo "<tr><td>";
echo $row[id];
echo "</td><td>";
echo $row[Code];
echo "</td><td>";
echo $row[Name];
echo "</td><td>";
echo $ExpLeft;
echo "</td></tr>";
}
echo "</table>";
paginate($display, $pg, $total);
include 'library/closedb.php';
?>
</body>
</html>
ExpLeft should be in DATE format, and you should store there expiry date, eg. 2007-01-23 then
let's say you want 12 months expiry still:
$ExpLef = (int)$_POST['EexpLef'];// = 12 (in months) int to force any string, etc into a number
Then the query could be
SELECT * FROM `pharmacy` WHERE `ExpLeft` >= DATE_SUB(CURDATE(),INTERVAL $EcpLef MONTH) ORDER BY id ASC LIMIT $start, $display;
this will return all that have expiry date above 2007-12-05
Hope this helps
Michal