Re: [PHP] Piping data into a select box

2002-01-13 Thread Dean Householder

Thank's for the help!
Dean

- Original Message -
From: Jimmy [EMAIL PROTECTED]
To: Dean Householder [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Sunday, January 13, 2002 12:33 AM
Subject: Re: [PHP] Piping data into a select box


 Hi Dean,

  Does anyone know how to give a select pulldown box a default value
  from a PHP variable?

 ?
 function generate_option_list ($key_value,$set) {
 // This function will return option list and set the selected attribute
 // $key_value : the associative array which contain the key and the value
for each option
 // $set : the value to be selected by deafult
 //
 // Usage: for example we want to have a dropdown list of month, and set
February as selected
 //
 //   $key_value=array(01=January,02=February,...);
 //   $option_list=generate_option_list($key_value,02);
 //   //$option_list now contain text option value='01'January/option
 //   //  option value='02'
selectedFebruary/option
 //
 // NOTE: This will only create the OPTION tag, without the SELECT tag
 //

   while ( list($key,$value) = each($key_value) ) {
 if ($key==$set) {$var.=option value='$key'
selected$value/option;}
 else {$var.=option value='$key'$value/option;}
   }
   return $var;
 }

 ?

 --
 Jimmy
 
 Leave loved ones with loving words, it may be the last time you see them





-- 
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] Piping data into a select box

2002-01-12 Thread Dean Householder

Does anyone know how to give a select pulldown box a default value from a PHP variable?

I've been able to figure out how to pipe data into every type in input  type of form 
element except for a select  element.  Any solutions would be helpful!

Dean



Fw: [PHP] Piping data into a select box

2002-01-12 Thread hugh danaher


- Original Message -
From: hugh danaher [EMAIL PROTECTED]
To: Dean Householder [EMAIL PROTECTED]
Sent: Saturday, January 12, 2002 7:12 PM
Subject: Re: [PHP] Piping data into a select box


 Dean, give this a try.

  form action=?php print $php_self? method=post
  ?php
  select type=text name=table STYLE=width:180px option ;
  for ($i=0;$i=$num;$i++)
   {
   print option.mysql_tablename($tables,$i);   // or.  i.e.
 $some_array[$i]
   }
  print /select;

  echo table .$table;

 hugh


 - Original Message -
 From: Dean Householder [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Saturday, January 12, 2002 6:01 PM
 Subject: [PHP] Piping data into a select box


 Does anyone know how to give a select pulldown box a default value from a
 PHP variable?

 I've been able to figure out how to pipe data into every type in input 
 type of form element except for a select  element.  Any solutions would
be
 helpful!

 Dean




-- 
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]




Re: [PHP] Piping data into a select box

2002-01-12 Thread Jimmy

Hi Dean,

 Does anyone know how to give a select pulldown box a default value
 from a PHP variable?

?
function generate_option_list ($key_value,$set) {
// This function will return option list and set the selected attribute
// $key_value : the associative array which contain the key and the value for each 
option
// $set : the value to be selected by deafult
//
// Usage: for example we want to have a dropdown list of month, and set February as 
selected
//
//   $key_value=array(01=January,02=February,...);
//   $option_list=generate_option_list($key_value,02);
//   //$option_list now contain text option value='01'January/option
//   //  option value='02' selectedFebruary/option
//
// NOTE: This will only create the OPTION tag, without the SELECT tag
//

  while ( list($key,$value) = each($key_value) ) {
if ($key==$set) {$var.=option value='$key' selected$value/option;}
else {$var.=option value='$key'$value/option;}
  }
  return $var;
}

?

--
Jimmy

Leave loved ones with loving words, it may be the last time you see them



-- 
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]