First of all, I apologize because I am new to PHP programming. I would really appreciate anyone's help in trying to fix the code below. I am trying to write a reusable function that dynamically generates drop down menu options on my site, but the function isn't working. The idea is to query the id and name of topics from the MySQL database and populate the menu. However, the code below isn't working:
<?php
function dropdown($Id, $Name, $Table) {
echo "<select id='$Id' name='$Id'>";
echo "<option value=\"0\">Select Value</option>";
$query = "SELECT * FROM $Table";
$data = mysqli_query($dbc, $query);
while($row = mysqli_fetch_array($data)) {
$strA = $row['$Id'];
$strB = $row['$Name'];
echo "<option value=\"$strA\">$strB</option>";
}
echo "</select><br />";
}
dropdown(type_id, name, usertype);
?>
For some reason the error is complaining about the "$query=" line. But the same syntax works elsewhere in my code. Any thoughts?
much appreciated!

Sign In
Register
Help

MultiQuote