php forms - select menu selected behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have the code below being used to rifle through a list of available
categories and create select options for them. The code is being used to
query the database and compare the product category to the current
iteration, if there's a match, then add selected code so the category is
prechosen. More code (not included) does the saving and all that, I've check
phpmyadmin. But when the page submits, the old category appears in the drop
down as selected. If I leave the page and come back it's fine, it's just
right after it is saved. The form script is being used on itself, in that
there is only one file for the form, the submission, etc. All of the other
input elements will load the data after being saved, is it something
specific to dropdowns, or it is the way the code is being instatiated?

All help is much appreciated. Please let me know if anymore info is needed.

//MAKE CATEGORIES DROPDOWN
$sql="SELECT * FROM categories ORDER BY category";

$catmatch="SELECT * FROM product WHERE dbi='$dbi'";
$catresult=mysql_query($catmatch);
$catquery=mysql_fetch_array($catresult);
//for($a=0;$a<mysql_fetch_array($catresult)){
//echo $catquery['prod_cat0'];
//}
$result=mysql_query($sql);

$catlist1="";
while ($col2=mysql_fetch_array($result)) {
    $id=$col2["category"];
    if($id==$catquery['prod_cat0']){
    $catlist1.="<option value=\"$id\"
selected=\"selected\">".$id."</option>";
  }
    else {
    $catlist1.="<option value=\"$id\">".$id."</option>";
  }

}

to instantiate <?=$catlist1?>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux