0
Within a select in the bank, I look for the expiry date of the product. I need it calculated by changing a status in the 'winning', 'critical' and beaten' response. I’m trying to do it this way below, but I’m a little rusty.
<?php
if($tabela == 'controle_insumos') {
$sql = mysql_query("SELECT controle_insumos.*, prod01.* FROM controle_insumos INNER JOIN prod01 ON controle_insumos.rwc = prod01.procod LIMIT 200 ");
while ($result = mysql_fetch_array($sql) )
{
echo "<tr>";
echo "<td>".$result['rwc']."</td>";
echo "<td>".$result['prodes']."</td>";
echo "<td>".$result['quantidade']."</td>";
echo "<td>".$result['pround']."</td>";
echo "<td>";
echo date('d/m/Y', strtotime($result['data_compra']));
echo "</td>";
echo "<td>";
echo date('d/m/Y', strtotime($result['fabricacao']));
echo "</td>";
echo "<td>";
echo date('d/m/Y', strtotime($result['validade']));
echo "</td>";
$data2 = new DateTime($result['validade']);
$data1 = new DateTime();
$intervalo = $data1->diff($data2);
if ($intervalo<0) {
echo "<td style='background: red;'>";
echo $intervalo->format('%R%');
echo "</td>";
}
elseif ($intervalo<30) {
echo "<td style='background: green;'>";
echo $intervalo->format('%R%');
echo "</td>";
}
elseif ($intervalo>90) {
echo "<td style='background: blue;'>";
echo $intervalo->format('%R%');
echo "</td>";
}
echo "</tr>";
}
}
else
$sql = mysql_query("SELECT $res_codigo as rwc, $res_nome as descricao, $res_un as unidade FROM $tabela order by RAND() LIMIT 200 ");
if($sql== 0)
$sql = mysql_query("SELECT $res_codigo as rwc, $res_nome as descricao, $res_un as unidade FROM $tabela order by RAND()");
while ($result = mysql_fetch_array($sql) )
{
echo "<tr>";
echo "<td>".$result['rwc']."</td>";
echo "<td>".$result['descricao']."</td>";
echo "<td>".$result['unidade']."</td>";
echo "<td><button class='btn btn-lg btn-primary btn-block' type='submit'>Comprar</button></td>";
echo "</tr>";
}
?>
In fact, the code does not end there. It remains whole
– Gustavo
then what would be your doubt? what is not working?
– Luiz Felipe
It worked! Sorry! thanks for the help!
– Gustavo