If I have a table In database which called occupations columns are: workid, workname, salary and sector workid is a primary key and increase I insert to the table 1, fireman , 500, 2 2, officer, 800, 1 the code in html / php Will show a drop menu select the workname from the table in the database so the menu will show the fireman and the officer As soon the user choose one of them(onchange) will be a textbox display just the salary The code will create a dropdown menu of all the occupations in the table in the database. When the user chooses one of the occupations, the corresponding salary will be displayed under the dropdown menu. I did the dropdown and it's connected to the database but when I click / chooce one of it they don't show the salary. would you complete the
If I have a table In
columns are: workid, workname, salary and sector
workid is a primary key and increase
I insert to the table
1, fireman , 500, 2
2, officer, 800, 1
the code in html / php
Will show a drop menu select the workname from the table in the database so the menu will show the fireman and the officer
As soon the user choose one of them(onchange)
will be a textbox display just the salary
- The code will create a dropdown menu of all the occupations in the table in the database. When the user chooses one of the occupations, the corresponding salary will be displayed under the dropdown menu.
- I did the dropdown and it's connected to the database but when I click / chooce one of it they don't show the salary. would you complete the missing part in my code
-
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname="occupation";// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}$result=mysqli_query($conn, "Select * from occupation1");
echo"<center>";
echo"<h1>Dropdown Menu</h1>";
echo"<select>";
echo"<option>-- Occupations --</option>";while($row=mysqli_fetch_array($result))
{echo"<option>$row[workname]</option>";
}
echo"</select>";
?>
Step by step
Solved in 4 steps with 2 images