Jump to content

using an evaulation with text box and radio buttons


mrsrowe

Recommended Posts

Hello

 

I'm still working on a peer review thing.  I have my users in groups.  When they log in the page gets populated with the members of their group.

 

Each person gets evaluated according to a scale from 3 for the lovely useful ones to -3 for the ones who don't show up much and when they do they are drunk or something.

 

Anyway.

 

I worked out - with help from here - how to grab the grades and userids and send them to the DB, now I've been asked to add a text box for when someone gets a very low mark to make the reviewer justify why they have given such a low mark.

 

This has stuffed up my lovely code.  Here is the stuff that populates the table with the radio buttons

 

echo '<tr>';
	echo '<td>' . $StudentID . '</td>';
	echo '<td>' . $FirstName . '</td>';
	echo '<td>' . $SurName . '</td>';
	echo '<td><input name="rating[' . $StudentID . ']" type="radio" value="-3" /></td>';
	echo '<td><input name="rating[' . $StudentID . ']" type="radio" value="-2" /></td>';
	echo '<td><input name="rating[' . $StudentID . ']" type="radio" value="-1" /></td>';
	echo '<td><input name="rating[' . $StudentID . ']" type="radio" value="0" /></td>';
	echo '<td><input name="rating[' . $StudentID . ']" type="radio" value="1" /></td>';
	echo '<td><input name="rating[' . $StudentID . ']" type="radio" value="1" /></td>';
	echo '<td><input name="rating[' . $StudentID . ']" type="radio" value="3" /></td>';

 

I would like to add something like this:

echo '<td><input name="Comment" type="text" /></td></tr>';

 

But then I'm at a loss as to how to handle the code as at the moment it's set up like this:

 

if(isset($_POST['submitted'])) {		
		echo 'submitted!<br />';
		foreach ($_POST['rating'] as $k=>$v) {

		echo "$k, $v <br />";

		$IQuery = "INSERT INTO tblResult (itmRated, itmScore) VALUES ('$k','$v')";

 

How can I get it to add the Comments into the code?

 

If I alter the code the only way I really understand

		if(isset($_POST['submitted'])) {		
		echo 'submitted!<br />';
		$Comment = ($_POST['Comment']);
		foreach ($_POST['rating'] as $k=>$v) {

		echo "$k, $v, $Comment <br />";

		$IQuery = "INSERT INTO tblResult (itmRated, itmScore, Comment) VALUES ('$k','$v','$Comment')";

 

it will only pick up one comment.

 

It needs to go into the array with the key and value pair, but I don't know how to do this.

 

I hope this makes sense.

 

Help really appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.