NYCPHP Meetup

NYPHP.org

[nycphp-talk] Newbie question - multi-select list box

Jeff jsiegel1 at optonline.net
Fri May 2 10:32:27 EDT 2003


Small clarification.

Here is the post variable from the multi-select box (I used
print_r($_post) to get this). DL_mCategories is the name of the select
box. 

 [DL_mCategories] => Array ( [0] => 2 [1] => 11 [2] => 3 ) 

The question is, how do I manipulate that array so that the multi-select
box is "preselected" with the user's selections. That is, when the form
posts to itself I don't want the user's selections to disappear.

Jeff

-----Original Message-----
From: Neeraj Rattu [mailto:neerajrattu at consultant.com] 
Sent: Friday, May 02, 2003 9:10 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Newbie question - multi-select list box


Get data from database. You should get it in a Array if you have stored
every thing in one field which i hope you have done it.

Now simply explode it and display it.

I could not get any help from the web. So i did it my way. Hope this
will help you


<?php
$Parking = explode("," ,$PropertyDetails[Parking_Garaging]);
//$count = count($Parking);
//echo $Parking[$i];
//while($count < 4)
//for($i=0;$i<=5;$i++)
foreach ($Parking as $value)
{
if($value =="Carport")
{
$value1 = $value;
}
if($value =="Single Garage")
{
$value2 = $value;
}
?>
<select name="Parking_Garaging[]"  multiple size="6">
<option value="Carport"
<?php
//if($PropertyDetails[Parking_Garaging]=="Carport")
if($value1 =="Carport")
{
echo "Selected";
}
?>
>Carport</option>
<option value="Single Garage"
<?php
//if($PropertyDetails[Parking_Garaging]=="Single Garage") if($value2
=="Single Garage") { echo "Selected"; } ?>
>Single Garage</option>

Regards,
Neeraj Rattu
Project Manager(PHP/MYSQL/APACHE/LINUX)
InterLink Marketing Systems
----- Original Message -----
From: Jeff <jsiegel1 at optonline.net>
Date: Fri,  2 May 2003 08:34:31 -0400
To: NYPHP Talk <talk at nyphp.org>
Subject: [nycphp-talk] Newbie question - multi-select list box

I have a multi-select list on a form that posts to itself. However,
while other items, such as text boxes retain their values (I'm using
something like <?php echo $_POST['DL_sAddr2'] ?> ) I'm scratchin' my
head on how to do the same with the multi-select list.

TIA,

Jeff







-- 
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup



--- Unsubscribe at http://nyphp.org/list/ ---






More information about the talk mailing list