0

I am creating a form with inputs type radio. I have retrieved the previous responses from the database and I put them in an array. And this is the result:

array(19) { ["1.1"]=> int(5) ["1.2"]=> int(2) ["1.3"]=> int(5) ["1.4"]=> int(2) ["1.5"]=> int(2) ["1.6"]=> int(4) ["1.7"]=> int(1) ["1.8"]=> int(3) ["1.9"]=> int(5) ["2.1"]=> int(5) ["2.2"]=> int(3) ["2.3"]=> int(1) ["2.4"]=> int(4) ["2.5"]=> int(2) ["3.1"]=> int(5) ["3.2"]=> int(5) ["3.3"]=> int(4) ["3.4"]=> int(3) ["4.1"]=> int(4) } 

I have got here the question number 1.1 and the value 5. That its perfect, but when I send the form, new results by POST, are changing from 1.1 to 1_1 and so on like this:

array(19) { ["1_1"]=> string(1) "5" ["1_2"]=> string(1) "2" ["1_3"]=> string(1) "5" ["1_4"]=> string(1) "2" ["1_5"]=> string(1) "2" ["1_6"]=> string(1) "4" ["1_7"]=> string(1) "1" ["1_8"]=> string(1) "3" ["1_9"]=> string(1) "5" ["2_1"]=> string(1) "5" ["2_2"]=> string(1) "3" ["2_3"]=> string(1) "1" ["2_4"]=> string(1) "4" ["2_5"]=> string(1) "2" ["3_1"]=> string(1) "5" ["3_2"]=> string(1) "5" ["3_3"]=> string(1) "4" ["3_4"]=> string(1) "3" ["4_1"]=> string(1) "4" } 

I am putting in the input, name="$variable", a variable that it gives me exactly the same 1.1, but I do not know what it's changing it it.

<input type="radio" name="<?php echo $que_code; ?>" value="1"

In order to compare them I would like to change them back to 1.1, 1.2..and so on.

Adrian Vazquez
  • 327
  • 1
  • 6
  • 20
  • Please exhaustively search SO for your solution before posting your question, this will spare moderator time and reduce page bloat on SO. – mickmackusa Mar 27 '17 at 11:14

1 Answers1

0

Add some "namespacing" - Instead of doing:

<input type="radio" name="1.1" value="1" />

Do:

<input type="radio" name="data[1.1]" value="1" />

...and you wont experience this problem :)

Stuart
  • 6,630
  • 2
  • 24
  • 40