I have a question / problem, I want to insert in a table in my database a value that is PHP variable, when passing it through $ _POST it does not keep it, is there another way to do it ?, I leave the code, maybe I I made a mistake:
$totalprice=0;
foreach($_SESSION['pedido'] as $id => $value) {
$sql="SELECT * FROM producto WHERE Id IN (";$sql.=$id.",";$sql=substr($sql, 0, -1).") ORDER BY Tipo ASC";
$query=mysqli_query($bd, $sql);
while($row=mysqli_fetch_array($query)){
$subtotal=$_SESSION['pedido'][$row['Id']]['quantity']*$row['Valor'];
$totalprice+=$subtotal;
?>
<tr>
<td><?php echo $row['Descripcion'] ?></td>
<td><input type="text" class="form-control" placeholder="Cantidad" name="quantity[<?php echo $row['Id'] ?>]" size="5" value="<?php echo $_SESSION['pedido'][$row['Id']]['quantity'] ?>" /></td>
<td>$<?php echo $row['Valor'] ?></td>
<td>$<?php echo $_SESSION['pedido'][$row['Id']]['quantity']*$row['Valor'] ?></td>
</tr>
<?php
}
}
//echo $sql;
//exit;
?>
<div class="form-group">
<tr>
**<td colspan="4" name="total"><strong>Total:</strong> <?php echo $totalprice ?></td>**
</tr>
</div>
PS: What I want to save is the value of $ totalprice
When passing it through $ _POST, I should be passing it like this: $ Total = $ _POST [$ totalprice];
Is this correct? Please your answers.