RE: [PHP-DB] Opinions wanted - Multi select lists , implode explode

From: Date: Tue, 05 Oct 2004 01:00:36 +0000
Subject: RE: [PHP-DB] Opinions wanted - Multi select lists , implode explode
Groups: php.db 
Request: Send a blank email to php-db+get-36599@lists.php.net to get a copy of this message
sure, you can use a table set of values...if they change often its worthwhile doing it that way. if they chang einfrequently, then why do another db call? expensive in a high volume production environment... you can create a simalar array...as long as you pass the array formated in that particular method...it shold be no problem i prefer to store array values in the db as a csv list (comma separated value)...then its very easy to a. see what goes in in the db if you use seom gui tool to look at the data b. simple to manipluate when retreived... bastien
From: Stuart Felenstein <stuart4m@yahoo.com> To: Bastien Koert <bastien_k@hotmail.com>, php-db@lists.php.net Subject: RE: [PHP-DB] Opinions wanted - Multi select lists , implode explode Date: Mon, 4 Oct 2004 10:40:12 -0700 (PDT) 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 <bastien_k@hotmail.com> 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 <stuart4m@yahoo.com> To: php-db@lists.php.net 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
_________________________________________________________________ Designer Mail isn't just fun to send, it's fun to receive. Use special stationery, fonts and colors. 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*.

« previous php.db (#36599) next »