Code: Select all
function user_dropdown($ddname = "username", $selected = -1)
{
$ret = "<select name='$ddname' type='dropdown'>";
$q = "SELECT * FROM users ORDER BY username ASC";
$user_query = mysqli_query($db_conx, $q);
$numrows = mysqli_num_rows($user_query);
if ($selected == -1)
{
$first = 0;
}
else
{
$first = 1;
}
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
$ret .= "\n<option value='{$row['username']}'";
if ($selected == $row['username'] || $first == 0)
{
$ret .= " selected='selected'";
$first = 1;
}
$ret .= ">{$row['username']}</option>";
}
$ret .= "\n</select>";
return $ret;
}
The name of the select is $ddname, but it's not a form. Any idea how to get it to recognize the $ddname name to write out the database information?
I've tried using the iffset:
Code: Select all
if(isset($_POST['$ddname ']))
{