Re: [PHP] $_POST variable

2011-03-12 Thread tedd

At 6:07 PM -0600 3/12/11, Shawn McKenzie wrote:

On 03/12/2011 10:37 AM, tedd wrote:
 > Here's a demo:



 > http://php1.net/b/form-radio1/



 > Don't make it more complicated than it needs be.

My point exactly!  So long as the name of the name[] part is the same
they will be treated as the same "group" of radio buttons.

So here is the long and short; if the name is the same and you specify
an index then names with the same index will be grouped together:
name[1] and name[1] are the same but different group from name[2].  If
you don't specify an index, but the name is the same, then they are
grouped together:  name[], name[].

By grouped together I mean that only one of the group can be selected
and therefore successful on submit.

--
Thanks!
-Shawn



Yeah, that's clear as mud -- I know how to do it and that confused me. :-\

Here's a much simpler example than my previous one:

http://rebel.lcc.edu/sperlt/citw229/sticky-radio.php

You don't even need an array. Just check the "choice" variable.

Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] $_POST variable

2011-03-12 Thread Shawn McKenzie
On 03/12/2011 10:37 AM, tedd wrote:
> At 9:28 PM +0200 3/11/11, Danny wrote:
>> Hi guys,
>>
>> I have a form that has a long list of radio-bottons inside of it. The
>> radio-buttons are dynamically created via php and MySQL.
>>
>> Here is an example of one of the radio buttons:
>>
>> > ?>" value="0">
>> > ?>" value="1">
>>
>> Now, when I submit this form to another page for processing, how would
>> I "catch"
>> the above radio-button's $_POST name since I do not know the name,
>> only that it
>> starts with "radio_" ?
>>
>> Thank You
>>
>> Danny
> 
> 
> Danny:
> 
> Replace  with an option[]
> array.
> 
> Realize that the name of the radio input stays the same -- it is the
> value that changes.
> 
> Here's a demo:
> 
> http://php1.net/b/form-radio1/
> 
> Don't make it more complicated than it needs be.
> 
> Cheers,
> 
> tedd
> 

My point exactly!  So long as the name of the name[] part is the same
they will be treated as the same "group" of radio buttons.

So here is the long and short; if the name is the same and you specify
an index then names with the same index will be grouped together:
name[1] and name[1] are the same but different group from name[2].  If
you don't specify an index, but the name is the same, then they are
grouped together:  name[], name[].

By grouped together I mean that only one of the group can be selected
and therefore successful on submit.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] $_POST variable

2011-03-12 Thread tedd

At 9:28 PM +0200 3/11/11, Danny wrote:

Hi guys,

I have a form that has a long list of radio-bottons inside of it. The
radio-buttons are dynamically created via php and MySQL.

Here is an example of one of the radio buttons:

; ?>" value="0">
; ?>" value="1">


Now, when I submit this form to another page for processing, how 
would I "catch"
the above radio-button's $_POST name since I do not know the name, 
only that it

starts with "radio_" ?

Thank You

Danny



Danny:

Replace  with an option[] array.

Realize that the name of the radio input stays the same -- it is the 
value that changes.


Here's a demo:

http://php1.net/b/form-radio1/

Don't make it more complicated than it needs be.

Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] $_POST variable

2011-03-11 Thread richard gray

On 11/03/2011 20:28, Danny wrote:

Hi guys,

I have a form that has a long list of radio-bottons inside of it. The
radio-buttons are dynamically created via php and MySQL.

Here is an example of one of the radio buttons:

" 
value="0">
" 
value="1">

Now, when I submit this form to another page for processing, how would I "catch"
the above radio-button's $_POST name since I do not know the name, only that it
starts with "radio_" ?


foreach ($_POST as $k => $v) {
if (substr($k,0,6) == 'radio_') {
echo 'Name is -> ',$k,'';
// Do stuff...
}
}

HTH
Rich

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



Re: [PHP] $_POST variable

2011-03-11 Thread Steve Staples
On Fri, 2011-03-11 at 21:28 +0200, Danny wrote:
> Hi guys,
> 
> I have a form that has a long list of radio-bottons inside of it. The
> radio-buttons are dynamically created via php and MySQL.
> 
> Here is an example of one of the radio buttons:
> 
> " 
> value="0">
> " 
> value="1">
> 
> Now, when I submit this form to another page for processing, how would I 
> "catch"
> the above radio-button's $_POST name since I do not know the name, only that 
> it
> starts with "radio_" ?
> 
> Thank You
> 
> Danny
> 

loop thought all the $_POST variables...

foreach($_POST as $key => $val)
{
if(susbtr($key, 0, 7) === "radio_")
{
# this is what we're looking for
}
}

crude, but works... I am sure there are many ways to look for it.

Steve


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



Re: [PHP] $_POST variable

2011-03-11 Thread Daniel Brown
On Fri, Mar 11, 2011 at 14:28, Danny  wrote:
[snip!]
>
> Now, when I submit this form to another page for processing, how would I 
> "catch"
> the above radio-button's $_POST name since I do not know the name, only that 
> it
> starts with "radio_" ?

One method is a foreach() loop.

 $v) {
if (preg_match('/^radio_/Ui',trim($k))) {
echo $k.' is a match, and it\'s value is '.$v.'.'.PHP_EOL;
}
}
?>

-- 

Network Infrastructure Manager
http://www.php.net/

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



[PHP] $_POST variable

2011-03-11 Thread Danny
Hi guys,

I have a form that has a long list of radio-bottons inside of it. The
radio-buttons are dynamically created via php and MySQL.

Here is an example of one of the radio buttons:

" 
value="0">
" 
value="1">

Now, when I submit this form to another page for processing, how would I "catch"
the above radio-button's $_POST name since I do not know the name, only that it
starts with "radio_" ?

Thank You

Danny

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



Re: [PHP] $_POST[$variable]

2003-12-11 Thread Chris Garaffa
On Dec 11, 2003, at 8:02 AM, Christian Jancso wrote:

Hi there,

I have the following problem:
How can I use variables in the $_POST statement?
Here is my code:
$old_station[$o] = $_POST['$i'];
$new_station[$o] = $_POST['$i'];
Christian,

My biggest question is: What are $i and $o set to?
Unless $i is set to a string with the same name as POST variable you're 
trying to access, this code won't work.

--
Chris Garaffa
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] $_POST[$variable]

2003-12-11 Thread CPT John W. Holmes
From: "Christian Jancso" <[EMAIL PROTECTED]>

> I have the following problem:
> How can I use variables in the $_POST statement?
> Here is my code:
>
> $old_station[$o] = $_POST['$i'];
> $new_station[$o] = $_POST['$i'];

$old_station[$o] = $_POST[$i];
$new_station[$o] = $_POST[$i];

Variables are not evaluated within single quotes, so  you were making a
literal key of "$i".

$old_station[$o] = $_POST["$i"];
$new_station[$o] = $_POST["$i"];

Will work, also, as the variable $i will be evaulated within the double
quote string.

---John Holmes...

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



[PHP] $_POST[$variable]

2003-12-11 Thread Christian Jancso
Hi there,

I have the following problem:
How can I use variables in the $_POST statement?
Here is my code:

$old_station[$o] = $_POST['$i'];
$new_station[$o] = $_POST['$i'];


echo "";
echo "";

while ($status_array = mysql_fetch_array($status))
{
$i++;
echo "";
echo ""."";
echo $status_array[1];
echo "";
echo "";
echo "".""."";
echo "";
echo "";
}

echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo ""; 

can anyone help me?

thx for your help

Christian

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