your checking the value every time you loop so that you can see if that value is 
checked or not. Im sure Ive missunderstood your question... please email.

<?php
  
 function selected($val_1, $val_2)
 {
  if ($val_1 == $val_2)
   return ' selected ';
  else
   return;
 }
 
 include_once('database_class.egn');

 $result = $database->select_array('', 'country', '');

 echo "
 <form method='post' action='$PHP_SELF'>
 
 <select name='country'>
 ";

 foreach($result as $pos => $val)
 {
  $this_country = $val['country'];
  
  echo "
  <option value='$this_country'". selected(@$country, $this_country) .">$this_country
  ";
 }
 
 echo "
 </select>
 
 <input type='submit' name='done' value='Submit'>
 </form>
 ";

?>


-- 

 Chris Lee
 Mediawaveonline.com

 ph. 250.377.1095
 ph. 250.376.2690
 fx. 250.554.1120

 [EMAIL PROTECTED]



"Nicole Lallande" <[EMAIL PROTECTED]> wrote in message 
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Hi,

Working on a code that uses a select/option field.  All my other fields
are passing through to the form processing software just fine.  Meloni's
PHP Essentials does this funky thing, declaring each function value as
selected or not although she shows it with the individual values not
with variable - and I don't understand why she is doing that - I don't
see it anywhere else.  What I do know is whether I try her if_else
selected method or without, my value is not being passed through http.   

echo "<td width=\"550\" align=\"left\"><select
name=\"select_product\">";
echo "<option value=\"\">Cat. ID No? Description  Pkg Size 
Price</option>";  
  
       while ($row = mysql_fetch_array($result)) {
         $catid[] = $row["Cat_ID"];       
}
       for ($i=0; $i < sizeof($catid); $i++) {
         $cat = $catid[$i];                 

  if($select_product =="cat") {
     echo "<option value=\"$cat\" selected>$cat</option>";
  } else {
     echo "<option value=\"$cat\">$cat</option>";
  }   

Thanks,

Nicole                                                
-- 
########################
Nicole Lallande
[EMAIL PROTECTED]
760.753.6766
########################

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to