I try to add a number of days or another depending on whether the field Date_Pending is established.
If it is, 30 days are added to that date. If it is not, add 15 days to the Opening_date.
I can not get it to work, I think the problem is in the condition.
<?php
try {
$conexion = new PDO('mysql:host=localhost;dbname=basedatos', 'user', 'password');
} catch (PDOException $e) {
echo "ERROR: " . $e->getMessage();
die();
}
$fechas = $conexion->prepare("
SELECT SQL_CALC_FOUND_ROWS * FROM incidencias
LIMIT 10
");
$fechas->execute();
$fechas = $fechas->fetchAll();
echo $fechas;
fecha1 = date('Y-m-j');
$fecha1 = $fecha['Fecha_Apertura'];
$nuevafecha1 = strtotime ( '+15 day' , strtotime ( $fecha1 ) ) ;
$nuevafecha1 = date ( 'Y-m-j' , $nuevafecha1 );
fecha2 = date('Y-m-j');
$fecha2 = $fecha['Fecha_Pendiente'];
$nuevafecha2 = strtotime ( '+30 day' , strtotime ( $fecha2 ) ) ;
$nuevafecha2 = date ( 'Y-m-j' , $nuevafecha2 );
?>
<div class="contenedor">
<h1>Fechas</h1>
<section class="fechas">
<ul>
<?php foreach ($fechas as $fecha){
if (!$fecha['Fecha_Pendiente']) {
$fecha3 = $nuevafecha1;
} else{
$fecha3 = $nuevafecha2;
}
} ?>
<li><?php echo $fecha['Fecha_Apertura'] . '//' . $fecha['Fecha_Pendiente'] . '//' . $fecha3 ?></li>
<?php endforeach; ?>
</ul>
</section>
</div>
Thanks
Achieved:
The idea is: If the Last Claim Date is not = 0 you must add 30 days to this date and show it in Next Update. If it is 0, it must add 15 days to the Opening Date.
<?php
try {
$conexion = new PDO('mysql:host=localhost;dbname=basedatos', 'user', 'password');
} catch (PDOException $e) {
echo "ERROR: " . $e->getMessage();
die();
}
$fechas = $conexion->prepare("SELECT * FROM CSC_Navegaciones LIMIT 10");
$fechas->execute();
$fechas = $fechas->fetchAll();
?>
<div class="contenedor">
<h1>Fechas</h1>
<section class="fechas">
<ul>
<?php foreach ($fechas as $fecha):
$fecha1 = date('Y-m-d');
$fecha1 = $fecha['Fecha_Apertura'];
$nuevafecha1 = strtotime ( '+15 day' , strtotime ( $fecha1 ) ) ;
$nuevafecha1 = date ( 'Y-m-d' , $nuevafecha1 );
$fecha2 = date('Y-m-j');
$fecha2 = $fecha['Fecha_Ultima_Reclam'];
$nuevafecha2 = strtotime ( '+30 day' , strtotime ( $fecha2 ) ) ;
$nuevafecha2 = date ( 'Y-m-d' , $nuevafecha2 );
if ($fecha2 != 0){$nuevafecha = $nuevafecha2;
}
else{ $nuevafecha = $nuevafecha1;
}
?>
<span> Fecha de Apertura ||| Fecha Ultima Reclamacion ||| Fecha Proximo Update</span>
<li><?php echo $fecha['Fecha_Apertura'] . ' |||| ' . $fecha['Fecha_Ultima_Reclam'] . ' ||| ' . $nuevafecha ?></li>
<?php endforeach; ?>
</ul>
</div>