elianero elianero - 14 days ago 4
MySQL Question

Simple Math with tables PHP

I have a table called

$row['seuil_pil']
that contains only numbers. And i want to increse these numbers by a certain amount but it doesn't work.

Here's my code:

$roof=0.12;

$seuil_haut= array_product(($row['seuil_pil']*$roof) + $row['seuil_pil']);


OR

$seuil_haut= array(($row['seuil_pil']*$roof) + $row['seuil_pil']);


OR

$seuil_haut= ($row['seuil_pil']*$roof) + $row['seuil_pil'];


OR

foreach ($row['seuil_pil'] as $seuil_haut[])
{
$seuil_haut[] = ($roof * $row['seuil_pil'] + $row['seuil_pil'] );
}

Answer

Use a foreach:

$roof = 0.12;

foreach($row['seuil_pil'] as $entry) {
    $entry *= (1 + $roof);
}