View Single Post
Old 07-05-2007, 06:40 AM   #1 (permalink)
white10
Junior Member
 
white10's Avatar
 
Join Date: 10-05-06
Posts: 23
iTrader: 0 / 0%
Latest Blog:
None

white10 is liked by many
Radio Buttons and mysql

Hi Guys

I am loading a test from a database, which contain all the questions and possible answers, Now what i want to do is display the possible answers as radio buttons and check if the user selected the correct radio button.(i will use the variable $cat_letter to check the value of the radio button selected.)

I want to checked if each radio button selected is equal to $cat_letter and then add 1 to it if not add 0 and conitue with the while loop

Can any of you guys be of help to me...

Code:
<?php session_start(); include "db_connect.php"; $get_cats = "select * from tests1"; $get_cats_res = mysql_query($get_cats) or die(mysql_error()); if (mysql_num_rows($get_cats_res) < 1) { $display_block = "<P><em>Sorry, no categories to browse.</em></p>"; } else { $display_block .= " <table width='574' border='1' cellpadding='0' cellspacing='0' > <tr> <td> <h2>$cat_title </h2> </td> </tr>"; $hold[]; while ($cats = mysql_fetch_array($get_cats_res)) { $cat_id = $cats[id]; $cat_description = stripslashes($cats[description]); $cat_letter = stripslashes($cats[letter]); $cat_answer_a = stripslashes($cats[answer_a]); $cat_answer_b = stripslashes($cats[answer_b]); $cat_answer_c = stripslashes($cats[answer_c]); $display_block .= "<tr> <td width ='30' class='style17'>$cat_id <td/> <td align='center' width ='294' bgcolor='white' class='style19'>$cat_description<td/> <td width ='80'> $cat_answer_a <INPUT TYPE='radio' NAME='one' VALUE='a' 'checked' > $cat_answer_b <INPUT TYPE= 'radio' NAME=\"one\" VALUE=\"b\" > $cat_answer_c <INPUT TYPE= 'radio' NAME=\"one\" VALUE=\"c\" > <td> </tr>"; } $display_block .= "</table>"; } ?>
white10 is offline   Reply With Quote