I've echoed the following php and it shows up properly in HTML so that can't be a problem:
PHP
if (mysqli_num_rows($result) > 0) {
//create the drop down menu
$list ="";
while($row = mysqli_fetch_assoc($result)) {
$list = '<div class="dropOption">'.$row["item"].'</div>';
}
This outputs three rows - apple, pear, strawberry - in the right div format.
And when I put the following php script into the jquery function below, the menu does contain the value strawberry (the last), however the first two are missing.
JavaScript
//drop down menu
$(document).ready(function(){
function createDropdown(){
var drop = $('#customDropdown');
var i;
var htmlString = '<div id="dropContainer">';
htmlString += '<?php echo $list;?>';
htmlString += '</div>';
drop.append(htmlString);
}
createDropdown();
I'm new to jquery and php so forgive me if the error is simple; however I'm pretty sure it's right, functionally speaking, because I'm getting something; so I figured the syntax must get be wrong somewhere. Can anybody help? Thanks in advance.