aCotoExpet
New Member
I have this code to collect categories from the field "category" from Mysql, it is a part editing form, i want the category that was selected before to be selected after the list is filled, the code is :\[code\] <td align="right">Category</td> <td> <?php // Write out our query. $query = "SELECT id,cat_name,parent FROM categories WHERE parent='0'"; // Execute it, or return the error message if there's a problem. $result = mysql_query($query) or die(mysql_error()); $dropdown = "<select name='category'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='http://stackoverflow.com/questions/15461543/{$row['id']}'>{$row['cat_name']}</option>"; } $dropdown .= "\r\n</select>"; echo $dropdown; ?> </td>\[/code\]I don't know how to do it? i know that i should type "selected" on the option i want to select but how to choose it after i filled the list?