คำนวณค่าปรับโดยค่าปรับเก็บส่งในฐานข้อมูล

  ตารางค่าปรับมีดังนี้
ลำดับ วันที่เกิน อัตราค่าปรับ 
            $date       $fine
  1          3              3
  2          5              5
  3          7              7
 
ถ้า คำนวณวันที่เกินมา 4($retern) ให้เอา $retern เปรียบเทียบกับ $date แลัว $retern * $fine

เขียนออกมาแล้วครับ

<?
$date=4;
include "connect.php";
$cmd="select max(fine_date) from fine";mysql_query($cmd,$link);
$result=mysql_query($cmd,$link);
$r=mysql_fetch_row($result);
$date_max=$r[0];
 
?>
<?
if($date>=$date_max){
$cmd="select * from fine  where fine_date ='$date_max' ";
mysql_query($cmd,$link);$result = mysql_query($cmd,$link);$row=mysql_fetch_row($result);
$i=$row[2]*$date;
echo"$i ค่าปรับ $row[2] ";
}else{
$cmd = "select * from fine ORDER BY fine_id ASC";
$result = mysql_query($cmd,$link);
while($row=mysql_fetch_row($result))
{
?>
<?
if($date<=$row[1]){
$i=$row[2]*$date;
echo"$i ค่าปรับ $row[2]";
break;
}
}
?>
<?
}
?>

ถ้าส่งวันที่เกินมา 4 วัน โปรแกรมมันจะให้อัตราค่าปรับ เป็น 5 ไม่เป็น 3
ทั้งที่ยังไม่ถึง 5 วันเลยครับ
ช่วยที ช่วยที
 


  


04 พ.ย. 2552 2 2,781

อันนี้ php หาวันข้างหน้า date("m-d-Y",strtotime("+4 day",time()));

แต่ไม่รู้มันจะช่วยคุณได้มากหรือป่าวนะคับ อิอิ

#1

งงมากมาย

ไม่รู้เป็นไร พักนี้ดูคำถามไม่ค่อยเข่าใจ ....
#2
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^