Hi all,
I'm working on a website who sells books, and I need some help here is the thing.. I have table of 2 rows and 7 columns in each row, in each column there is radio button with a certain value inside .. now I need to make next preview page where I show which price has been selected in the two rows. The number of rows with radio-buttons isn’t fixed, so I need to make sure that my code can handle this. Does anyone have suggestion for me, get me going towards right direction would be great as well.
Thank you
radio buttons
Moderator: General Moderators
Re: radio buttons
I'm not entirely sure I understand exactly what you're going for, but maybe this is what you need...
So.. depending on your row/column structure...
Something like that. Does that help any?
Code: Select all
<input type="radio" name="rad[0]" value="a" />
<input type="radio" name="rad[0]" value="b" />
<input type="radio" name="rad[0]" value="c" />
<input type="radio" name="rad[1]" value="a" />
<input type="radio" name="rad[1]" value="b" />
<input type="radio" name="rad[1]" value="c" />
<input type="radio" name="rad[2]" value="a" />
<input type="radio" name="rad[2]" value="b" />
...etcCode: Select all
for ($i=0; $i < $columns; $i++) {
for ($n=0; $n < $rows; $n++) {
echo '<input type="radio" name="rad[', $i, '][', $n, ']" value="a" />',
'<input type="radio" name="rad[', $i, '][', $n, ']" value="b" />',
'<input type="radio" name="rad[', $i, '][', $n, ']" value="c" />';
}
}Code: Select all
foreach ($_POST['rad']) {
foreach ($_POST['rad'][column]) {
}
}Re: radio buttons
thank you m8, you've really helped .. tnx a zillio again ..