How to make an increment of one value every 3 inserted records?

0

Greetings, my problem is that every 3 inserted records I must make an increase in value, example: I have my table details_quotes in which I keep the amounts of each quota according to an established amount, but every time you insert 3 records you must increase the amount 20%. This is the function in which I insert:

function cuotas($cantidad,$monto){

$query = "INSERT INTO cuotas (cantidad,monto)VALUES('$cantidad','$monto')";
$sql = $mysqli->query($query);

$val = mysqli_insert_id($mysqli);

for($i=1; $i <= $cantidad; $i++){
  $query2 = "INSERT INTO 
detalle_cuotas(id_cuota,monto)VALUES('$val','$monto')";
  $sql2 = $mysqli->query($query2);
}

if($sql>0 && $sql2>0):
  header('Location:admin.php');
else:
  echo mysqli_error($mysqli);
endif;
} 

This should be the case the data in my table, every 3 that I insert increases 20%, but I really do not get the form

    
asked by 13.08.2017 в 01:02
source

0 answers