<?php $sql12 = 'SELECT * FROM factures WHERE n_doss=' . $_GET['n_doss'] . '';
$req7 = mysql_query ($sql12) or die ('Erreur SQL !<br>'.$sql12.'<br>'.mysql_error ());
while($data9 = mysql_fetch_assoc ($req7))
{ ?><?php } ?> après je suis bloqué je ne sais pas comment progresser.
$total_interet = 0;
$total_principal = 0;
$taux_interet = ?;
$sql = 'select facture, principal, echeance from table_facture where dossier = 1';
$query = mysql_query($sql);
while ($data=mysql_fetch_assoc($query))
{
$facture = $data['facture'];
$principal = $data['principale'];
$echeance = $data['echeance']; // faire une convertion en date php
$duree = calcul entre date du jour et echance cf doc PHP
$intéret = calcul principal & duree & taux
$total_interet += $interet;
$total_principal += $principal;
echo des données avec formatage
}
echo des totaux avec formatage
$duree par $duree= DATEDIFF(NOW(),$date_echeance)<?php $total_interet = 0;
$total_principal = 0;
$taux_interet = 0;
$sql = 'select * from factures where n_doss='.$_GET['n_doss'].'';
$query = mysql_query($sql);
while ($data=mysql_fetch_assoc($query))
{
$principal = $data['montant'];
$echeance = $data['date_echue'];
$duree= Date_diff(date('ymd'),$echeance);
$interet = $principal*($nb + ($duree*$taux) - $principal);
}
echo $interets ;
?>
Si quelqu'un peut m'aider. ca serait avec grand plaisir, la il me dit.
( ! ) Warning: date_diff() expects parameter 1 to be DateTime, string given in C:\wamp\www\NEOGETCASH\GESTIONNAIRE\tableau-central.php on line 108
Call Stack
# Time Memory Function Location
1 0.0017 951984 {main}( ) ..\creance.php:0
2 0.0421 1226688 include( 'C:\wamp\www\NEOGETCASH\GESTIONNAIRE\tableau-central.php' ) ..\creance.php:673
3 0.0433 1231752 date_diff ( ) ..\tableau-central.php:10
d'avance merci pour votre aide
<?php
$sql = 'select * from factures where n_doss='.$_GET['n_doss'].'';
$query = mysql_query($sql);
while ($data=mysql_fetch_assoc($query))
{
$principal = $data['montant'];
$echeance = $data['date_echue'];
$duree= $diff = abs(strtotime( date('Y-m-d')) - strtotime($echeance));
$interet = (1 + 0.06);
function puissance($x,$y)
{
$resultat=0;
for ($i=0;$i<$y;$i++)
$resultat *= $x;
return $resultat;
}
$ti= $principal*puissance($interet,$duree);
echo $ti ; }
?>
Non, si tu regarde la doc, c'est bien une chaine de caractère qui est renvoyée et pas un objet de type date :mais pourtant date(ymd), renvoit bien une date non?
string date ( string $format [, int $timestamp = time() ] )
Retourne une date sous forme d'une chaîne, au format donné par le paramètre format, fournie par le paramètre timestamp ou la date et l'heure courantes si aucun timestamp n'est fourni. En d'autres termes, le paramètre timestamp est optionnel et vaut par défaut la valeur de la fonction time().
<?php
$sql = 'select * from factures where n_doss='.$_GET['n_doss'].'';
$query = mysql_query($sql);
while ($data=mysql_fetch_assoc($query))
{
$principal = $data['montant'];
$echeance = $data['date_echue'];
$day= date('y-m-d');
$s = strtotime($day)-strtotime($echeance);
$d = intval($s/86400)+1;
$i = (0.06);
$tx= $principal*($i/360)*$d;
$i2= number_format($tx, 2, ',', ' ');
echo $i2 ;
}
?>