On my php edit page. When I submit the edit page, the data is stored correctly in de database. But when I reload the edit page again, it doesn't load the right value from the database. And only the default value (in this case it is cars) is showed. I hope someone have the answer for me..
Overview of the tables in the database:
Table: links
ID url title catparent
1 http:// buddy 3
2 http:// sports 2
3 http:// cars 1
Table: categories
ID catname
1 cars
2 sport
3 friends
The field catname from de table categories, contained the desired values for the pulldown menu.
Bellow I attached my current drop down code, what do I need to change to get it work?
//SELECT AND EDIT CATEGORY
print "Category:<br>";
$ID = $_GET['ID'];
$sql = "SELECT * FROM links where ID='$ID'";
$link_query = mysql_query($sql);
$link = mysql_fetch_array($link_query);
$sql = "SELECT * FROM categories ORDER BY ID ASC";
$category_query = mysql_query($sql);
echo '<select name="category">';
while( $category = mysql_fetch_array($category_query) ){
if( $link['catparent'] == $category['ID'] ){ $selected = ' selected="selected"'; }
echo '<option value="'.$category['ID'].'"'.$selected.'>'.$category['catname'].'</option>';
}
echo '</select><br>';
//SELECT AND EDIT CATEGORY
Thanks in advance: Rien