I have a kind of invoice in which a calculation is made of the user that loguea of how much should be paid in that month of invoice (is condominium) in the query where the calculation is done I add that you make insert data in a table to save the amount generated from that user in the month, but I have a problem that every time that user enters the module or page where the invoice is displayed is added to the table said amount, that is if it enters 10 times the page is added 10 times the data to the table, what I want to do is to add only 1 time per month (since the bill is monthly) no matter how many times you enter the page, this is the code ... referring to the part of the insert into receipt
<?php
error_reporting(E_ALL^E_NOTICE);
$ip_global = $_SERVER['REMOTE_ADDR'];
date_default_timezone_set('America/Guyana');
$global_fecha = date("d-m-y H:i:s");
require_once('../conexion.php');
$alicuota= $_SESSION['alicuota'];
$sql = "SELECT SUM( monto ) as total
FROM gasto_g
WHERE YEAR( create_at ) = YEAR( CURRENT_DATE( ) )
AND MONTH( create_at ) = MONTH( CURRENT_DATE( ) )
ORDER BY create_at ASC";
$Resultado = mysqli_query ($conexion,$sql);
while ($Datos = mysqli_fetch_array($Resultado)){
$alicuota= $_SESSION['alicuota'];
$total1=($Datos['0'] * $alicuota)/100;
$id= $_SESSION['id'];
$consulta = "INSERT INTO recibo VALUES('','$total1','$id')";
$query = mysqli_query($conexion, $consulta);
if ($query) {
?>
<?php
}
?>