Php 重温昨天';s数据并插入今天的数据';s数据
我正在做一个php mysql项目。 其中项目有两个表Php 重温昨天';s数据并插入今天的数据';s数据,php,mysql,Php,Mysql,我正在做一个php mysql项目。 其中项目有两个表 产品表 日销售额 其中每日销售额按库存计算。其中旧的_余额由昨天的当前余额更新。我的代码是这样的 if($oldbal==NULL && $datecur== 'systemdate'){ $datecur = $datecur - 1; $sql=mysql_query("SELECT current from sales where sales.date='$datecur'"); while($row =
if($oldbal==NULL && $datecur== 'systemdate'){
$datecur = $datecur - 1;
$sql=mysql_query("SELECT current from sales where sales.date='$datecur'");
while($row = mysql_fetch_array($sql)){
$oldbal=$row['current'];
$total=$oldbal + $receipt;
$sql="INSERT INTO sales (pcode,oldbal,receipt,total,current,date)
VALUES ('$_POST[pcode]','$oldbal','$_POST[receipt]','$total','$_POST[current]','$_POST[date]')";
}
}
else{
$total=$oldbal + $receipt;
$sql="INSERT INTO sales (pcode,oldbal,receipt,total,current,date)
VALUES ('$_POST[pcode]','$_POST[oldbal]','$_POST[receipt]','$total','$_POST[current]','$_POST[date');
}
在这一部分中,我要求用户不要输入旧的余额数据并检查今天的日期,我从数据库中提取当前余额以插入新元组。您的代码块不完整,如果,请在第一行的右括号前输入代码。请给我一分钟。您的问题是什么?我需要在更新行时获取当前余额(第三天的余额),每行在输入时都会更新。如果我不检索昨天的数据,所有数据都会更新。