I want to add a drop down menu on click to my page via java script however when added it does not retrieve the mysql value it just prints the code inside the drop down. Any suggestions:
Index.php
<script src="addInput.js" language="Javascript" type="text/javascript"></script>
<?php
include 'config.php';
include 'opendb.php';
$sql = "SELECT fullname FROM test";
$result = $conn->query($sql);
echo "<form action='process.php' method='post' <div id='dynamicInput'>
<select name='competitor1'>";
while ($row = $result->fetch_array()) {
$name = $row['fullname'];
echo "<option value='" . $row['fullname'] . "'>" . $row['fullname'] . " </option>";
}
echo "</select> </div>";
echo "<input type='submit' /></form>";
?>
<input type="button" value="Add another text input" onClick="addInput('dynamicInput');">
addInput.js
var counter = 1;
var limit = 3;
function addInput(divName){
if (counter == limit) {
alert("You have reached the limit of adding " + counter + " inputs");
}
else {
var newdiv = document.createElement('div');
newdiv.innerHTML = "Entry " + (counter + 1)
+ "<?php mysqli_data_seek($result, 0); ?>"
+ "<br><select name='competitor2'>"
+ "<?php while ($row = $result->fetch_array()) { echo \"<option value=\" . $row['fullname'] . \"/>\" . $row['fullname'] . \"</option>\";} ?>" + "</select>";
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}