J. Mick J. Mick - 5 months ago 14
SQL Question

change the value of a variable from the database with PHP and MySQLi

Hello friends greetings.

You help me please of how yo change the value of a variable from the database with PHP and MySQLi.

The matter is that I have this variable

$iva 16;


And I have this data in database MySQLi database name iva
id -> 1 value_iva -> 14


Now as change the value of the variable
$iva 16
from a query MySQLi.

That is change the value of the variable '16' and show the value that is in the database.

As I perform the query to display the value of VAT from the database.

Answer

This is a example friend, hope you serve greetings.

<?php

$sql = "SELECT * FROM iva ORDER BY id DESC";
//Query
$query = mysqli_query($c, $sql);

if (mysqli_num_rows($query) > 0 ) {
    if ($row = mysqli_fetch_assoc($query)) {    
        $iva = $row['iva'];

?>

<?php echo $iva; ?>


<?php
    }
} mysqli_close($c);
?>