[PHP] using foreach() to capture multiple selections

2004-09-21 Thread Luke Mackenzie
Subject: using foreach() to capture multiple selections

hi,

i would like to to put multiple selections from a form list into a single
variable using foreach but am unsure how to do so.

can someone advise how to adapt the following code?

?php

print You are interested in: ;

foreach($myGoals as $value)

{

print $value ;

}

?

 

- 
lukem  - quality custom t-shirts 
browse - www.lukem.co.uk 
contact- [EMAIL PROTECTED] 

need a new website? get over to 
http://www.lukem-sites.co.uk http://www.lukem-sites.co.uk/  

 


Re: [PHP] using foreach() to capture multiple selections

2004-09-21 Thread Greg Donald
On Tue, 21 Sep 2004 20:26:04 +0100, Luke Mackenzie [EMAIL PROTECTED] wrote:
 i would like to to put multiple selections from a form list into a single
 variable using foreach but am unsure how to do so.
 
 can someone advise how to adapt the following code?

?php

print You are interested in: ;

print select multiple name=\select_field[]\;

foreach($myGoals as $key = $value)
{
  print option value=\$key\$value/option;
}

print /select;

?

untested..


-- 
Greg Donald
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] using foreach() to capture multiple selections

2004-09-21 Thread John Holmes
From: Luke Mackenzie [EMAIL PROTECTED]
i would like to to put multiple selections from a form list into a single
variable using foreach but am unsure how to do so.
can someone advise how to adapt the following code?
print You are interested in: ;
foreach($myGoals as $value)
{
print $value ;
}
$var = implode(' ',$myGoals);
or
foreach($myGoals as $value)
{ $var .= $value . ' '; }
First method is easier. 

---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] using foreach() to capture multiple selections

2004-09-21 Thread Matthew Sims

 i would like to to put multiple selections from a form list into a single
 variable using foreach but am unsure how to do so.

 can someone advise how to adapt the following code?

 ?php

 print You are interested in: ;

 foreach($myGoals as $value)

 {

 print $value ;

 }

 ?

Not to do all the work for you but do you mean:


You are interested in:

form method=post action=phpPage.php

?php foreach ($myGoals as $value): ?
  input type=radio name=goals value=?php echo $value; ??php
echo $value; ?
?php endforeach; ?

/form


-- 
--Matthew Sims
--http://killermookie.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] using foreach() to capture multiple selections

2004-09-21 Thread Jason Wong
On Wednesday 22 September 2004 03:26, Luke Mackenzie wrote:
 Subject: using foreach() to capture multiple selections

 i would like to to put multiple selections from a form list into a single
 variable using foreach but am unsure how to do so.

manual  PHP and HTML

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
One monk said to the other, The fish has flopped out of the net! How will it
live? The other said, When you have gotten out of the net, I'll tell you.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] using foreach() to capture multiple selections

2004-09-21 Thread Janet Valade
Luke Mackenzie wrote:
Subject: using foreach() to capture multiple selections
hi,
i would like to to put multiple selections from a form list into a single
variable using foreach but am unsure how to do so.
can someone advise how to adapt the following code?
?php
print You are interested in: ;
foreach($myGoals as $value)
{
print $value ;
}
?
I'm not totally sure what you are looking for. It looks like you have 
values in an array $myGoals. I'm assuming you collected the form values 
in the array, so you have $myGoals[0], $myGoals[1], etc. Are you saying 
you want all the values in MyGoals added to a single variable as a 
string? If so, look at the function implode. 
www.php.net/manual/en/function.implode.php

Or, you can have a statement in your forrach loop something like:
$string .= $value. ;
Janet

 

- 
lukem  - quality custom t-shirts 
browse - www.lukem.co.uk 
contact- [EMAIL PROTECTED] 

need a new website? get over to 
http://www.lukem-sites.co.uk http://www.lukem-sites.co.uk/  

 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php