Need help to display data from DB
Posted: Tue Dec 29, 2015 6:51 am
Hi
I don't know how to display values from DB when i select a value from a selection menu, as you can see from the picture, if for exemple i select HEA140 from the menu I want to display the name and radius...

Here is the PHP code:
The picture of the DB:

Thank you for your help
I don't know how to display values from DB when i select a value from a selection menu, as you can see from the picture, if for exemple i select HEA140 from the menu I want to display the name and radius...

Here is the PHP code:
Code: Select all
<?php
$message = '';
$db = new MySQLi('localhost', 'root', '', 'profile');
if ($db -> connect_error){
$message = $db -> connect_error;
}else{
$sql = 'SELECT * FROM hea';
$result = $db -> query($sql);
if($db -> error){
$message = $db -> error;
}
}
?>
<!DOCTYPE html>
<html>
<header>
<title>Page2</title>
</header>
<body>
<form method="post">
<?php
if($message){
echo "$message";
}
echo "<select name='sub1'>";
while ($row = $result -> fetch_assoc()) {
echo "<option value='" . $row['nom'] . "'>" . $row['nom'] . "</option>";
}
echo "</select>";
if (isset($_POST['afficher'])){
echo "<br>";
echo 'Nom: ' . $row['nom'];
echo "<br>";
echo 'Hauteur: ' . $row['hauteur'];
echo "<br>";
echo 'Base: ' . $row['base'];
echo "<br>";
echo 'TW: ' . $row['tw'];
echo "<br>";
echo 'TF: ' . $row['tf'];
echo "<br>";
echo 'Rayon: ' . $row['rayon'];
echo "<br>";
}
?>
<input type="submit" name="afficher" value="Afficher">
</form>
</body>
</html>
The picture of the DB:

Thank you for your help