Reading and displaying Radio Button values from a Database.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
streambuffer
Forum Newbie
Posts: 4
Joined: Tue Jun 09, 2009 7:20 am

Reading and displaying Radio Button values from a Database.

Post by streambuffer »

Here's what needs to be done. It involves a PHP page getting data from an SQL database and then posting it back to the database to be viewed by the administrator.

There's an SQL DB with this table that contains the following fields: ( few rows filled with sample data)

CourseName...|....CourseID ....| ....TraineeID....|....Session |...Year...|...Instructorname...|...Section
Designing ...........#1................23437................Winter.......2009.......Jimmy Hendrix ..........B
Singing.................#2 ..............23437..................Fall .........2009......Mickey Mouse ............C
Dancing...............#3 ..............23437..................Fall......... 2009........Mickey Mouse ..........A
Clapping............. #8............. 23439...............Summer.......2009........George Jetson..........A

This was just the database part. Now we move to what the user sees in the browser. The user logs in via a login page and is taken to a PHP page with.

The purpose of the PHP page is to act as an Evaluation form for feedback from the user about the training courses that he has taken. Since it's a form, It will have radio buttons and the values displayed against the buttons are actually course Names (Designing, SInging etc.) and I need these values to be dynamic - to be read from the CourseName field in the table above via an SQL query. Also, the TraineeID is the login-name for the user and only the courses registered against that TraineeID are to be displayed in the form as illustrated below.

See attached image to get a rough idea of what that Evaluation Form will look like.


Example form layout (made in photoshop)
Example form layout (made in photoshop)
formdesc.jpg (34.7 KiB) Viewed 46 times

After selecting the course and clicking SUBMIT, the user will be taken to an evaluation questions form and that evaluation from will store its results in another table (e.g Eval_Data).


I know how to connect to a database and im using Dreamweaver CS3 with myPhpAdmin running.
Here are my two questions:

1-How do I make the Radio Button values dynamic?
Will the echo function in PHP work. Something like <?php echo $row['CourseName ']; />
Just for a suggestion, I pieced together some code that reads data from the database to fill values displayed for a radio button but its not my code so I'm not quite clear on it:

while($q1=mysql_fetch_array($q)) {
print "<input type='radio' name='radbutton' value='".$q1['CourseName']."'>".$q1['CourseName']."<br />";
}

How can a dreamweaver 'Recordset' be used here.

2-Once a course (Say, designing) has been evaluated and the user logs in again, I want the radio button against the previously evaluated course to be greyed out.

Can we use the isset function in PHP to somehow check the other table (Eval_data) for any blank or filled fields and then use Javascript to disable that button?

I know these are two different questions but both have unignorable significance and I would highly appreciate any help. Thank you :)
Post Reply