Trying to get values from mysql into <select>
tag.
I have used while loop & getting data from 2 different tables.
I have tried the given code but not able to get the data.
Please Help!
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
// Connect to server and select databse.
$conn=mysqli_connect($host,$username,$password) or die("cannot connect");
mysqli_select_db($conn,$db_name);
$result = mysqli_query($conn,"SELECT * from dummy");
$uresult=mysqli_query($conn,"SELECT name from user where role='Support'");
$uname=array();
while ($rows=mysqli_fetch_array($uresult))
{
$uname[]=$rows['name'];
}
echo "<table border='1' width='100%' >
<tr><th colspan='7' ><h2 align='center'>Details</h2></th></tr>
<tr bgcolor='grey'>
<th width='10%' class='text-center'>Emp No.</th>
<th width='15%' class='text-center'>Name</th>
<th width='30%' class='text-center'>Task</th>
<th width='20%' class='text-center'>Assigned To</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td align='center'>" . $row['emp_no']. "</td>";
echo "<td align='center'>" . $row['emp_name']. "</td>";
echo "<td align='center'>" . $row['task'] . "</td>";
echo "<td align='center'> <select name='select1'> <?php while ($rows=mysqli_fetch_array($uresult)) { ?><option><?php echo $rows['name'];?> </option><?php } ?> </select> </td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
?>
Error : Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)