how to save a value of mysql as php variable code example

Example 1: how to save the variable from query in mysql with php

$result = $db->query('Select `Name`, `Age`, `Color` from `People` ');
while ($rows = $result->fetch()){
$Name = $rows['Name'];
$Age = $rows['Age'];
$Color = $rows['Color'];
}

Example 2: how to save the variable from query in mysql with php

<p>
Hello, my name is <?php echo $Name; ?>. 
I am <?php echo $Age; ?> years old and my favorite color is <?php echo $Color; ?>.
</p>

Tags:

Php Example