JamesCliff
Programmer
Im using the following code to populate a listbox from a mysql table. I want it so when a value is selected from the listbox its ID is passed to a variable and this variable is used in a link to post the ID to another page. I can get the list to populate and i can select a value from the listbox but i cant figure out howto put the selected rows ID into a variable and use it on the same page just like you would do with a variable formed from a mysql query. This is the code im using:
Can someone tell me whats wrong?
Code:
<select name="user_id">
<?php
$sql2 = "select id, username from brisk_users order by username ASC";
$result2=mysql_query($sql2);
while ( $dropdown = mysql_fetch_array($result2) ){
if ($dropdown["id"]==$id){
echo("<option selected value=". $dropdown["id"]. ">" . $dropdown["username"] . "</option>");
}
else {
echo("<option value=". $dropdown["id"]. ">" . $dropdown["username"] . "</option>");
}
}
?>
</select>
<?php
$user_id = $user_id[0]
?>
</p>
<p> </p>
<p><font color="#4C4C4C" size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href="index.php?page=admin/login/hom3d7r/users/amend_user&user_id=<? echo "$user_id"; ?>">Change user access level</a><br>
</font></p>
<p><font color="#4C4C4C" size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href="index.php?page=admin/login/hom3d7r/users/del_user&user_id=<? echo "$user_id"; ?>">Delete selected user</a></font></p>
Can someone tell me whats wrong?