
mrsrowe
Members-
Posts
17 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
mrsrowe's Achievements

Newbie (1/5)
0
Reputation
-
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.
-
I didn't need to define $row because this works. and this is what I was looking for. $rating = $_GET["rating"][0]; AND i used the code tag. see learning all the time.
-
hello thanks. I don't know what you mean by a code tag, which is why I didn't use one. sorry.
-
sorry, i wanted to be quick. You are right, $row is defined after the data comes from the query, I thought this would persist on the button click, it appears in the location bar in the browser, so to my brain, it must still be available to use. i'm not a natural with this stuff. here is my code <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $selected = 1; $page_title = 'hello chips'; //page header echo '<h2>students</h2>'; require_once('ilikechips.php'); if(isset($_GET['submitted'])) { echo 'submitted!'; $rating = $_GET['rating'][$row['StudentID']]; } else { echo 'no button pushed here weakling'; } //query $query = "SELECT StudentID, SurName,FirstName FROM tblStudent WHERE GroupID= ' . $Selected . '"; $result = mysql_query($query); if($result) { //table header echo '<form action="viewStudentsSetVs.php" method="get">'; echo '<table border=1> <tr><td>ID</td> <td>Surname</td> <td>First Name</td> <td>-3</td> <td>-2</td> <td>-1</td> <td>0</td> <td>1</td> <td>2</td> <td>3</td> </tr>'; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $SurName = $row['SurName']; $FirstName = $row['FirstName']; $StudentID = $row['StudentID']; 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></tr>'; } echo '</table>'; echo '<input name="Submit" type="submit" value="go tiger" />'; //echo '<input type="hidden" name="submitted" value="TRUE" />'; echo '<input type="hidden" name="submitted" value="TRUE" />'; echo '</form>'; mysql_free_result($result); } else { echo ' the current users could not be retrieved.'; } //mysql_close() ?> this is the location bar contents: http://chipsarefantastic.com/viewStudentsSetVs.php?rating[1]=-3&Submit=go+tiger&submitted=TRUE
-
I've changed the action to get in order to see what is being sent though the browser: viewStudentsSetVs.php?rating[1]=-3&Submit=go&submitted=TRUE so it's picking up the variable and the value. But when the button is submitted it tells me this: Notice: Undefined variable: row in /data/www/sites/.../viewStudentsSetVs.php on line 24 Notice: Undefined index: in /data/www/sites/.../viewStudentsSetVs.php on line 24 why isn't it picking up the information? any help appreciated.
-
none of these are the same as the one your first suggested: <input name="rating[' . $row['StudentID'] . ']" type="radio" value="-3" /> so I'm a bit confused, I'm also getting lots of error messages :[
-
Thanks all of you. I did that and it works, sort of. How do I grab that value once the form is submitted? If I use this bit of code: if(isset($_GET['submitted'])) { //echo $StudentID; //echo $StudentID; $name = $_GET['rating']; //this is causing a fatal error. echo $name; //echo $FirstName; } else I get the response: Notice: Undefined index: rating How do it get it to append the value that is passed with 'rating'? Thanks
-
Hello I am creating a peer review page. I have 10 users in a group and they need to rate the other nine members in their group. for each member of the group there is a row in a table that has their name and then marks from -3 to 3 for their performance. My query calls the student name id and group from a table in the db. this pulls all the relevant users out and creates a table. However, the radio buttons all belong to the same group so I cannot select scores for each user individually, see below: <tr><td>' . $row['StudentID'] . '</td><td>' . $row['SurName'] . '</td><td>' . $row['FirstName'] . '</td><td><input name="rating" type="radio" value="-3" /></td><td><input name="rating" type="radio" value="-2" /></td><td><input name="rating" type="radio" value="-1" /></td><td><input name="rating" type="radio" value="0" /></td><td><input name="rating" type="radio" value="1" /></td><td><input name="rating" type="radio" value="1" /></td><td><input name="rating" type="radio" value="3" /></td></tr>' I want to change the input name from rating, to something unique to each user, for example to use the StudentID hope this makes sense. all answers appreciated.
-
Hello I am sure this is on the board somewhere, but I cannot find it. I had a db with a list of documents, some of these documents have files which can be downloaded. I have put the a link to the file name in the db, now I want to be able to create an icon which links to the file if it exists and shows nothing if there is no file. My query returns the title, abstract and some other stuff about the document. $query = "SELECT DocID, DocTitle, Abstract, DocLink, fileType FROM tblDoc ORDER BY PubYear DESC"; the table I echo it all out into is made like this: echo '<tr valign="top" bgcolor="' . $bg . '">'; echo '<td align="left">' . $row['DocTitle'] . '</td>'; echo '<td align="left">' . $row['Abstract'] . '</td>'; echo '<td align="left">' . $row['PubYear'] . '</td>'; I want to be able to do somthing like this: echo '<td align="left"><a href="eftec_reports/' . $row['DocLink'] . '"><img src="' . $row['fileType'] . '"></a></td>'; but of course it doesn't work. I am never sure how to refer to the things I want to use from the db. I think I need an if statement something like if DocLink is not null, then create an <a href.... and use an image to make the link active hope this makes sense. any help appreciated.
-
Hello thanks for the response, but a very quick look at GROUP BY seems to work as long as you have one entry per record. Unfortunately this isn't a very well formed table so one field can contain multiple keywords, for example one record could be like this Title Keywords Title1: apples, cheese, bread Title2: apples, cheese, cherries Is that going to work with GROUP BY? Don't I have to put them in an array, do something in the array that finds the individual words and then group them?
-
Hello I foolishly agreed to create a page that would read data from a table and spit it out into a web page. Once this was done I was asked to create a search page, which I did, then I was asked to restrict the search criteria to keywords that were in the database table, so I made a quick and dirty fix by downloading all of the terms and populating the drop down list. Now I have been asked if the drop down list could be populated directly from the table. I know I should have done that in the first place but there were so many entries and I thought they only wanted a quick soloution, so I didn't create related tables. Now I'm in a fix. The keywords field can look like this: apples, cheese, peaches or like this cheese, bread, cherries, apples I want to be able to create a drop down that would read: apples, bread, cheese, cherries, peaches I would like to know if it is possible to write some php that will return all of the data from the column, then look through all of the entries, compare them and then remove the duplicates. This data should then be able to populate the drop down, I can do that bit. This would mean that I wouldn't have to take their database to bits and create related tables. Perhaps I'm being lazy, perhaps this is more work than it's worth, but I'd like to know if it is possible. Any help appreciated. thanks
-
[SOLVED] does not return result on page, but does from db
mrsrowe replied to mrsrowe's topic in PHP Coding Help
stupid me, using wrong kind of "" marks grr -
Hello Im only an occaisional user of php and mysql, so I forget stuff, but this is driving me insane I have a form on an html page, i have a drop down which allows users to select a search term, the search term is sent to a php page; which takes the value and turns it into a variable, $valx i want to use this value to search for the term in my db. this is my query: "SELECT Doc, Abstract, Topic, DATE_FORMAT(pubYear, '%Y') AS MyYear, Keywords FROM tblDoc WHERE Topic LIKE $valx ORDER BY MyYear DESC"; This is returning nothing what so ever. In order to test if the variable was working did this echo "selected text was $valx"; which works I have tried substituting the variable for an actual value in the quey, for example "water" this returns all of the results, but I cannot get it to return the results when I use the value. I am completely flummoxed by this and any help that can be offered would be really appreciated. Thanks
-
Hello I'm not sure the best way to do this. I have a small database of documents, I would like users to be able to search for a date, or to search on a word - the relevant column has been indexed in the db, or to search on a set of pre-defined keywords. I have a form with a text box for the free text search, a drop down list for the keywords and a drop down list for the dates on the page which recieves the input, how do I best write the querey. Is it best to use a case statement, something like Case selected date, SELECT * FROM table WHERE chosenDate = $chosenDate break Case selected keyword SELECT * FROM table WHERE MATCH (Abstract) AGAINST ('$word') break Case SELECT * FROM table WHERE Keyword = $kWord or is there a more elegant way of writing the code. apologies if this is a bit wooly, it's sunday evening T
-
joining 3 tables, one of which has multiple entries
mrsrowe replied to mrsrowe's topic in MySQL Help
I'm using MySql MySql version 4.0.27, it appears not to work with versions earlier than 4.1 any other suggestions?