How to use while loop to loop a set of radio button groups? I have several questions that retrieve from database and each question has five different ratings named 1, 2, 3, 4 and 5. I create radio button group for the rating and using while to loop them. I know I have to create a unique name for radio buttons for each row but how to increment the value automatically for each row? I didn’t retrieve any value from database when I create the radio button group. All the data is arrange in the table. Besides, I need to save each selected value into database. I am using php. Anyone got ideas for my question. Thanks for your kindly reply.
star_lavender
0
Light Poster
Recommended Answers
Jump to PostHow to use while loop to loop a set of radio button groups? I have several questions that retrieve from database and each question has five different ratings named 1, 2, 3, 4 and 5. I create radio button group for the rating and using while to loop them. I …
Jump to Postcreate a variable before the loop and set its value to 1
inside the loop, call your radio button something like my_button_X where X is the value created above.
then add one to the variable before ending the loop.
You could also send the final value of …
Jump to Post<td><table width='900' border='1'> <tr> <td><div align='center'><strong>No.</strong></div></td> <td><div align='center'><strong>Question</strong></div></td> <td><div align='center'><strong>Rating</strong></div></td> <td><div align='center'><strong>Amount</strong></div></td> <td><div align='center'><strong>Remark</strong></div></td> </tr> <?php while($row = mysql_fetch_array($result)) { <td width="350" align="center" width="20"><?php echo $i;?></td> <td width="350"><?php echo $row[question];?></td> <td align="center" width="500"> <input type="radio" name="rating<?=$i?>" value="1"/>1 <input type="radio" name="rating<?=$i?>" value="2"/>2 <input type="radio" name="rating<?=$i?>" value="3"/>3 <input type="radio" …
Jump to PostThanks for the reply and it really works for me coz now I can select more than one radio button...but now how can I save all the data into the database?I declared the variable as $rating, $amount and $remark but it doesnt work as what I expected coz the data …
Jump to Posttry this now. i don't know how you are validating fields. thats why i am taking count of $rating . this is for just reference to you.
<? extract($_POST); //print_r ($rating); //print_r ($amount); //print_r ($remark); //$select=mysql_query("select * from questions "); //$count=mysql_num_rows($select); for($j=1;$j<=count($rating);$j++) { echo "INSERT INTO survey …
All 19 Replies
OS_dev
0
Junior Poster
star_lavender
0
Light Poster
slyme
27
Junior Poster in Training
rajabhaskar525
1
Junior Poster
star_lavender
0
Light Poster
star_lavender
0
Light Poster
star_lavender
0
Light Poster
muralibobby2015
17
Posting Pro
star_lavender
0
Light Poster
muralibobby2015
17
Posting Pro
muralibobby2015
17
Posting Pro
star_lavender
0
Light Poster
OS_dev
0
Junior Poster
BzzBee
5
Posting Whiz
star_lavender
0
Light Poster
OS_dev
0
Junior Poster
star_lavender
0
Light Poster
OS_dev
0
Junior Poster
star_lavender
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.