Jump to content

Populate pop up box with data from drop down field


ashrobbins87

Recommended Posts

I am making a page for user management, and part of it is letting the person using it view a drop down list of current users, then when they have chosen one they click 'View' to view the details in a pop up window. Trouble is, I cant get it to work. The code I'm working with is below...

$getUsers_sql ="SELECT id, firstname, surname FROM cms_users ORDER BY firstname";
$getUsers_res = mysqli_query($mysqli, $getUsers_sql)or die(mysqli_error()); 

echo '<select name="users">'; 
while ($row = mysqli_fetch_assoc($getUsers_res)) 
{ 
    echo '<option value="' . $row['id'] . '">' . $row['firstname'] . ' ' . $row['surname'] . '</option>'; 
} 
echo "</select>";

$f = $row['firstname'];
$s = $row['surname'];

echo"
<a href=\"javascript:eventWindow('user.php?f=".$f."&s=".$s."');\">
<input type=\"submit\" name=\"viewuser\" value=\"View\" />
</a>";

 

I know the query is right, but when I hover over the View button when I'm testing, it says the fields are empty.

 

Ok I've changed it to ...

$getUsers_sql ="SELECT id, firstname, surname FROM cms_users ORDER BY firstname";
$getUsers_res = mysqli_query($mysqli, $getUsers_sql)or die(mysqli_error()); 

echo '<select name="users">'; 
while ($row = mysqli_fetch_assoc($getUsers_res)) 
{ 

    echo '<option value="' . $row['id'] . '">' . $row['firstname'] . ' ' . $row['surname'] . '</option>'; 
$f = $row['firstname'];
$s = $row['surname'];
} 
echo "</select>";



echo"
<a href=\"javascript:eventWindow('user.php?f=".$f."&s=".$s."');\">
<input type=\"submit\" name=\"viewuser\" value=\"View\" />
</a>";

 

...so now at least it shows that there is something in the variables when I hover over the "View" button. But it always goes to the last record, not the record selected in the drop down. Any clues??

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.