<?php
require ("init.php");
?>
<head>
<script src="ajax.js"></script>
<script src="common.js"></script>
</head>
<body>
<?php
$query = "SELECT * FROM User1";
$result = mysqli_query($connection, $query);
echo '<form> ';
echo "Select a Users:";
echo '<select name="users" onchange="showUser(this.value)">';
while ($row=mysqli_fetch_assoc($result)){
echo $row=['Username'];
echo '<option value="'.$row=['Username'].'">'.$row=['Username'].'</option>';
}
echo '</select></form>';
?>
<div id="txtHint"><b>User info will be listed here.</b></div>
</body>
the problem i am having is that the drop down box only shows array multiple times and does not show usernames from my database however the connection to my database is working as when tryed debugging it got it to echo out just one username
IT should be like this:
while ($row=mysqli_fetch_assoc($result)){
//echo $row=['Username']; //Invalied here
echo '<option value="'.$row['Username'].'">'.$row['Username'].'</option>';
}
No need that =
sign.
Correct:
echo $row=['Username'];// This is unnecessary.
echo '<option value="'.$row=['Username'].'">'.$row=['Username'].'</option>';// what is = doing here?
To:
echo '<option value="'.$row['Username'].'">'.$row['Username'].'</option>';