Okay, well a couple of questions. If you don't mind.
Right below is the code I have , and the multiple list
box is filled with values and labels from a table.
So may I ask:
1-Can I replace the array_list and match if I use a
table instead of manual values ?
2-Also - curious to know how people store array values
in a database .
<td><select name="Tax[]" size="2" multiple="multiple"
id="Tax[]">
<?php while(!$rsTax->EOF){
?>
<option value="<?php echo
$rsTaxTerm->Fields('TaxID')?>"><?php echo
$rsTaxTerm->Fields('Tax')?></option>
<?php $rsTax->MoveNext();
}
$rsTax->MoveFirst();
?>
Stuart
--- Bastien Koert <[EMAIL PROTECTED]> wrote:
> I've used it sucessfully many times. It may the
> other person's unfamiliarity
> with arrays and variables
>
> I created the below function which will handle both
> single choice and
> multiple choice drop down values and mark them as
> selected when the user
> views that drop down again.
>
>
> bastien
>
> <?
> function
> my_select($name,$rows,$multiple,$array_list,$match)
> {
> //this select box takes the above 5 arguements to
> create details
> /*
> 1. $name = the name of the select box
> 2. $rows = the number of displayed rows (1 as
> the default)
> 3. $multiple = does the select allow multiple
> choices (boolean value 0
> for no, 1 for yes
> 4. $array_list = the options (in a value:display
> pair ie
> "1:Informatique","2:Voyages","3:Immobilier")
> 5. $match = the items to be selected if trying
> to keep a value ( is ""
> if no values present or comma separated list if
> multiple)
>
>
> */
>
> $numOpts = count($match);
> if ($numOpts>1){
> $matches=implode(",",$match);
> }elseif ($numOpts==1){
> $matches=$match;
> }else{
> $matches="";
> }
>
> echo "<select name=\"$name\" ";
> echo "size=\"$rows\" ";
> if ($mutiple==1){ echo " MULTIPLE "; }
> echo ">";
>
> $count=count($array_list);
>
> for ($i=0;$i<$count;$i++){
> //take apart the array key:value pairs
> $elements = explode(":",$array_list[$i]);
>
> //compare matches to list to see if the item is
> selected
> if (($numOpts<2)&&($matches == $elements[0])){
> echo "<option value=\"".$elements[0]."\"
> SELECTED>".$elements[1];
>
>
}elseif(($numOpts>1)&&(in_array($elements[0],$matches))){
> echo "<option value=\"".$elements[0]."\"
> SELECTED>".$elements[1];
> }else{
> echo "<option
> value=\"".$elements[0]."\">".$elements[1];
> }
> }//end for
> echo "</select>";
>
> }//end function
> ?>
>
>
> >From: Stuart Felenstein <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: [PHP-DB] Opinions wanted - Multi select
> lists , implode explode
> >Date: Mon, 4 Oct 2004 09:46:20 -0700 (PDT)
> >
> >I was just told that having an array pulling
> multiple
> >selections from a user out of a list box is a bad
> >practice.
> >
> >Can this be true ?
> >I was under the assumption it was perfectly
> effective.
> >
> >
> >Thank you,
> >Stuart
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
_________________________________________________________________
> Take charge with a pop-up guard built on patented
> Microsoft� SmartScreen
> Technology
>
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
>
> Start enjoying all the benefits of MSN� Premium
> right now and get the
> first two months FREE*.
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php