![]() ![]() ![]() |
|
function error($error){
echo " *** WARNING ".$error;
}
function checkStock($stock){
global $db;
$days_result = mysql_query("SELECT DATEDIFF( (SELECT date FROM stock) , NOW() ) AS days")
or error("Could not retrieve amount of days until restock. : ". mysql_error());
$days = mysql_fetch_assoc($days_result);
return $days['days'];
}
$db_server = "localhost";
$userName = "hfx_order_sys";
$passwd = "osHFX0094";
$db = mysql_connect($db_server, $userName, $passwd)
or error("Could not connect to mysql : " . mysql_error());
//selecting the database
mysql_query("USE hfx_order_sys",$db)
or error("Could not select database: ".mysql_error());
$stock_result = mysql_query("SELECT * FROM stock LIMIT 1")
or error("Could not check stock availability. : ".mysql_error());
while($stock = mysql_fetch_assoc($stock_result)) {
$available = checkStock($stock);
}
if($available > 0){
?>
Ordering has been suspended temporarily while we restock HeightFX. Sorry for the inconvenience. HeightFX will be available for order again within the next echo $available; ?> days. Please check back soon!
. } ?> |