Hello all,

i have a question regarding a mysql populated selectbox, i managed to fill this with data from a table, but now i want to show the selected value from another table ( with the same value of course).

here is my selectbox now:

<select name="project" class="selectbox" tabindex="1"> 
$sql = "SELECT descr FROM project"; 
$rs = mysql_query($sql); 
while ($r = mysql_fetch_array($rs)) {
echo "<option value=\"".$r["descr"]."\">".$r["descr"]."</option>"; 

in another table, called 'build' i store the same descr as in the project table, i want to select that one, by id that is, and show that one as selected in the selectbox.

can anyone help me out?

6 Years
Discussion Span
Last Post by Excizted

Initially store the descr of the selected one (get it from mysql).
Then in your while loop, you check if $r == $your_new_variable;

If it is, then you echo "selected" in your <option> tag.

Votes + Comments
thanks for helping
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.