我有一张名为“treat_period”的表,用来存储每只山羊接种疫苗的固定天数,还有一个order_details表,用于存储山羊购买时的信息。现在,treat_period表具有如下列,并具有相应的数据: id(1)、productID(山羊)、treat1(90)、treat2(180)、treat3(270)、treat4(360)、Peranalal热处理(365)。我想知道山羊是否已经分别呆了90天和180天。这是我的密码,请帮忙。
<?php
$treat_query = mysql_query("select * from treat_period where productID='$product_id'") or die(mysql_error());
$treat_row = mysql_fetch_array($product_query);
$treatperiod1=$treat_row['treat1'];
$thisDate = date("Y-m-d");
$allDays = $treatperiod1;
$usedDays = round(abs(strtotime($thisDate)-strtotime($orderdate))/60/60/24);
$Daysremaining = $allDays-$usedDays;
if($Daysremaining==0)
{
echo "<a target = '_blank' href ='request_pay.php?order_id=$order_id&orderdate=$orderdate' class='btn btn-success'><i class='fa fa-pencil'></i>Vaccinate Gaoat</a>";
}
else
{
echo $Daysremaining.' Days Left for Vaccination';
}
?>发布于 2016-09-06 17:39:05
$Daysremaining = ceil(abs(strtotime($thisDate) - strtotime($orderdate)) / 86400);
if($treatperiod1==$Daysremaining){
echo "<a target = '_blank' href ='request_pay.php?order_id=$order_id&orderdate=$orderdate' class='btn btn-success'><i class='fa fa-pencil'></i>Vaccinate Gaoat</a>";
}else {
echo $Daysremaining.' Days Left for Vaccination';
}发布于 2016-09-06 21:07:44
后来,我发现名为“treat_period”的表并不是在<?php echo $treat_row['treat1']; ?>之后替换存储的记录,但是如果我从order_details表中替换信息,那么就决定向order_details表(treat1、treat2等)添加更多的列,使用相同的代码,我现在可以得到预期的结果。请看这里的代码。
<?php
$treatperiod1=$product_row['treat1'];
$currentDate = date("Y-m-d");
$totalDays = $treatperiod1;
$usedDays = round(abs(strtotime($currentDate)-strtotime($orderdate))/60/60/24);
$remainingDays = $totalDays-$usedDays;
if($remainingDays==0)
{
echo "<a target = '_blank' href ='product_addon.php' class='btn btn-success'><i class='fa fa-pencil'></i>Vaccinate Gaoat</a>";
}
else
{
echo $remainingDays.' Days Left for Vaccination';
}
?>谢谢
https://stackoverflow.com/questions/39354514
复制相似问题