How to generate dynamic radio buttons in php

How to generate dynamic radio buttons in php

<?
$arrX = array('Ben','Sam','Will');
foreach ($arrX as $value) {
	echo "<input type=\"radio\" name=\"RadioGroup1\" value=".$value." />".$value."<br />";
}
?>

CMIIW :)

What do you mean 'is not working' ? What error are you getting ?

i was not able to any output from this code...

Use <?php instead of <? (very bad habit).

Matti Ressler
Suomedia

Use <?php instead of <? (very bad habit).

Matti Ressler
Suomedia

I don't think thats the problem. Because, If short tags are disabled on his computer, it will just print the 'code' as text.

I don't think thats the problem. Because, If short tags are disabled on his computer, it will just print the 'code' as text.

Well that depends on which browser they are using.


Matti Ressler
Suomedia

My actual question was how do i create radio buttons in a loop

for eg:
for($i=0;$i<10;$i++)
{
echo '<input type="radio" name="name[$i]" value=$i>abc';
echo '<input type="radio" name="name[$i]" value=$i>def';
}

how can i select 10 radio buttons out of this 20 buttons ang get the value of these buttons......