Jump to content

Update record - list/menu issues


argrafic

Recommended Posts

Hello all.

 

I have the insert form that has 3 list/menus.

 

When I want to update a record I gather all the information and show it with a form.

 

My problem is with the values the list/menus have, because so far they appear with the default value which if the user doesn't see might overwrite withouth their knowledge the wrong value.

 

How can I get the list/menu to match the value saved in the database?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/104388-update-record-listmenu-issues/
Share on other sites

:D sorry...

 

i have the regular insert form that has 3 list/menus, one gets the values from the database, the others have "static" content.

 

then i also have a update form for the values stored in the database for the insert form.

 

my issue is that when i load the info to the update form i want to know if there is a way that for the list/menus the option that appears is the one stored in the database and not the first value in the list/menu.

 

i don't know... i hope i explained it better...

Do something like this:

 

<?php
//DROPDOWN MENU: Category
$selectcat = "SELECT catname FROM icategory order by catorder";
$resultcat = mysql_query($selectcat) or trigger_error("SQL", E_USER_ERROR);
while($cat = mysql_fetch_row($resultcat))	//set $row to a row array from the query results
{
$catMenu = $cat[0];	//assign a var to each element in the array
if ($catMenu == $pcategory) {
	$cats = $cats . "<option value=\"$catMenu\" selected>$catMenu</option> ";
} else {
	$cats = $cats . "<option value=\"$catMenu\">$catMenu</option> ";
}
}
//End DROPDOWN MENU: Category
?>

 

and insert the $cats into your <select>

 

<?php
print "<select name=\"pcategory\">$cats</select>";
?>

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.