php - edit form on click select options from another table for updating data
one text
When user click on edit button it shows form with all field filled with corresponding data.
*Main Issue I am unable to deploy select options from another table in single query
QUERY
$emid=$_POST['editid'];
$conn=mysqli_connect('localhost','root','','ajaxdemo') or die('connection failed');
$msql="SELECT * FROM employee WHERE emid='$emid'";
after while loop:
<div class='form-group'>
<select >
<option value='{$row['supname']}' >{$row['supname']}</option>
</select>
</div>
table where data stored and also supplier name, table name: employee
supplier name coning from this table name: supplier
NOTE don't go for table names i am just practicing
my full code if want to see:
<?php
$emid=$_POST['editid'];
$conn=mysqli_connect('localhost','root','','ajaxdemo') or die('connection failed');
$msql="SELECT * FROM employee WHERE emid='$emid'";
$result=mysqli_query($conn, $msql);
$output="";
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
$output.= "
<div class='form-group'>
<input type='text' hidden class='form-control' id='editemid' value='{$row['emid']}'>
</div>
<div class='form-group'>
<input type='text' class='form-control' id='editfname' value='{$row['fname']}'>
</div>
<div class='form-group'>
<input type='text' class='form-control' id='editlname' value='{$row['lname']}'>
</div>
<div class='form-group'>
<select >
<option value='{$row['supname']}' >{$row['supname']}</option>
</select>
</div>
<div class='form-group'>
<input type='button' class='btn btn-primary btn-block' value='Update' id='updateform'>
</div>
";
}
$output.= " </table>";
echo $output;
}else{
echo "Record Not Found";
}
?>
Source