|
incrementing by number a row with a specific user name in a table row
01-18-2010, 08:41 AM
|
incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
hi, ive looked all over google and cant find out how to do this in sql. i have a field with an id, an name, and several attributes about that person that people vote on. the problem is, if the user enters the same name, i dont know how to update that row with the new vote.
here is the code i have so far, any help GREATLY appreciated. thanks. derek
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
$grade = "null";
if ($average <= 1) {
$grade = "F";
echo "Your friend has a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "Your friend has a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "Your friend has a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "Your friend has a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "Your friend has a grade of <strong>A.</strong> ";
}
if(isset($_COOKIE['guest_cookie'])) {
$cookie_ip = $_COOKIE['guest_cookie'];
$user_ip = $_SERVER['REMOTE_ADDR'];
if ($cookie_ip == $user_ip) {
echo "you have already voted for this friend";
} else {
if(isset($_POST['Submit'])){
/* mysql_query("INSERT INTO friendgrade (grade , friend,zip,loyalty,courtesy , stability, attitude)VALUES('$grade', '$field2','$field3','$field4','$field5','$field6' , '$field7')");*/
UPDATE friendgrade SET courtesy = courtesy + $field4 , stability =
stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7;
}//end isset
}//end else
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
01-18-2010, 08:48 AM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
|
UPDATE table SET column = column + [number] WHERE criteria = [whatever];
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
01-18-2010, 08:56 AM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
thanks very much chris, notice the update statement i added, but it wont go into the database now.
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
/*if(isset($_COOKIE['guest_cookie'])) {
$cookie_ip = $_COOKIE['guest_cookie'];
$user_ip = $_SERVER['REMOTE_ADDR'];
}
if ($cookie_ip == $user_ip) {
echo "you have already voted for this friend";
} else {
*/
if(isset($_POST['Submit'])){
/*mysql_query("INSERT INTO friendgrade (grade , friend,zip,loyalty,courtesy , stability, attitude)VALUES('$grade', '$field2','$field3','$field4','$field5','$field6' , '$field7')");*/
mysql_query("UPDATE friendgrade SET courtesy = courtesy + $field4 , stability = stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7 WHERE friend = '$field2'");
// }//end else
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
if ($average <= 1) {
$grade = "F";
echo "$field2 has a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "$field2 has a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "$field2 has a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "$field2 has a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "$field2 has a grade of <strong>A.</strong> ";
}
}//end isset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
Last edited by silverglade; 01-18-2010 at 10:00 AM..
|
|
|
|
01-18-2010, 11:01 AM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
|
Error message?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
01-18-2010, 02:16 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
awesome i got it to work. the only thing is, i cant average the new data that is entered, and change the friends grade based on that. also, a user could enter infinite ratings because i have no cookie or anything stopping from doing it. but here is the code. it adds up the attributes and puts the number in the appropriate fields, updating a single persons name attributes. thats about it.
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
if(isset($_POST['Submit'])){
if ($average <= 1) {
$grade = "F";
echo "$field2 has a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "$field2 has a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "$field2 has a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "$field2 has a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "$field2 has a grade of <strong>A.</strong> ";
}
mysql_query("INSERT INTO friendgrade (grade, zip, friend, courtesy,stability,loyalty,attitude) VALUES('$grade' , '$field3','$field2', $field4 , $field5, $field6, $field7 ) ON DUPLICATE KEY UPDATE courtesy = courtesy + $field4 , stability = stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7");
}//end isset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
01-18-2010, 05:39 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
I need to know all the vote values, then divide them by the total, to get average
but where do i store all the vote values? I have to store all the votes for each specific friend. but how? man thats a brain cruncher.then i have to be able to update the grade based on all of the averages. any help greatly appreciated.
here is my current code
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
if(isset($_POST['Submit'])){
if ($average <= 1) {
$grade = "F";
echo "$field2 has a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "$field2 has a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "$field2 has a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "$field2 has a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "$field2 has a grade of <strong>A.</strong> ";
}
///you need to know all the vote values, then divide them by the total, to get average
///where do i store all the vote values? you have to store all the votes for each specific friend. but how? then i have to be able to update the grade based on all the averages.
mysql_query("INSERT INTO friendgrade (grade, zip, friend, courtesy,stability,loyalty,attitude) VALUES('$grade' , '$field3','$field2', $field4 , $field5, $field6, $field7 ) ON DUPLICATE KEY UPDATE courtesy = courtesy + $field4, stability = stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7");
}//end isset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
Last edited by silverglade; 01-18-2010 at 05:50 PM..
|
|
|
|
01-18-2010, 05:49 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
|
PHP Code:
select AVG(column1 + column2 + ... + columnN) AS av WHERE userid = NN;
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
01-18-2010, 05:52 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
thanks again chris. i dont really understand that code. could you please explain it just a little bit so i can put it in my database and script? please. derek
|
|
|
|
01-18-2010, 06:07 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
|
having relooked at my code that will not calculate the average.
I would suggest a restructuring of your tables to make the whole thing simpler and more efficient.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
01-18-2010, 06:12 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
thanks. i dont know how to do that though. the code i made is the best i could do. do you know if there is code i could use to hold all the votes for each friend attribute and calculate the averages, then use those to average the grade for "friend"? sorry im such a newbie. if you cant thats ok. thanks. derek
|
|
|
|
01-18-2010, 06:20 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
|
Quick suggestion without too much thought, would be to have all the "grades" in a separate table and join them on the userid.
id - numeric - [record number]
uid - numeric [FK for user table]
type - char - [code to identify which grade]
value - numeric - [value for the grading]
vid - numeric - [id of voter]
that covers another of your questions. How to stop fake voting.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
01-18-2010, 06:35 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
|
|
|
|
01-18-2010, 07:23 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
hi again, lol. i added a search to display a row based on the input friend name. but nothing prints out, the row doesnt print out. any help greatly appreciated. thanks. derek here is the code
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$find = $_POST['find'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
if(isset($_POST['Submit'])){
if ($average <= 1) {
$grade = "F";
echo "$field2 has a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "$field2 has a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "$field2 has a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "$field2 has a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "$field2 has a grade of <strong>A.</strong> ";
}
///you need to know all the vote values, then divide them by the total, to get average
///where do i store all the vote values? you have to store all the votes for each specific friend. but how? then i have to be able to update the grade based on all the averages.
/*Quick suggestion without too much thought, would be to have all the "grades" in a separate table and join them on the userid.
id - numeric - [record number]
uid - numeric [FK for user table]
type - char - [code to identify which grade]
value - numeric - [value for the grading]
vid - numeric - [id of voter]
that covers another of your questions. How to stop fake voting.*/
mysql_query("INSERT INTO friendgrade (grade, zip, friend, courtesy,stability,loyalty,attitude) VALUES('$grade' , '$field3','$field2', $field4 , $field5, $field6, $field7 ) ON DUPLICATE KEY UPDATE courtesy = courtesy + $field4, stability = stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7");
}//end isset
if(isset($_POST['submit'])){
$query="SELECT * FROM friendgrade WHERE name='$find' LIMIT 1";
$result=mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$userinfo = mysql_fetch_array($result);
echo $userinfo;
}
else
{
echo "Invalid username"; // or whatever
}
}//end isset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
<table width="335" border="1">
<tr>
<td width="325"> search friends
<input type="text" name="find" id="find" /> </td>
</tr>
<tr>
<td><input type="submit" name="search" id="search" value="search" /></td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
01-19-2010, 09:35 AM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
ok here is what i have so far, i added some new sql , but on the find friend search i get "invalid username" any help greatly appreciated. thanks .derek.
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field1 = mysql_real_escape_string($field1);
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field1 = $_POST['randomnumber'];
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$find = $_POST['submit'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
if(isset($_POST['Submit'])){
if ($average <= 1) {
$grade = "F";
echo "$field2 has a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "$field2 has a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "$field2 has a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "$field2 has a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "$field2 has a grade of <strong>A.</strong> ";
}
///you need to know all the vote values, then divide them by the total, to get average
///where do i store all the vote values? you have to store all the votes for each specific friend. but how? then i have to be able to update the grade based on all the averages.
/*Quick suggestion without too much thought, would be to have all the "grades" in a separate table and join them on the userid.
id - numeric - [record number]
uid - numeric [FK for user table]
type - char - [code to identify which grade]
value - numeric - [value for the grading]
vid - numeric - [id of voter]
that covers another of your questions. How to stop fake voting.*/
mysql_query("INSERT INTO friendgrade (randomnumber, grade, zip, friend, courtesy,stability,loyalty,attitude) VALUES('$field1','$grade' , '$field3','$field2', $field4 , '$field5',' $field6', '$field7' ) ON DUPLICATE KEY UPDATE courtesy = courtesy + $field4, stability = stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7");
}//end isset
if(isset($_POST['submit'])){
$query="SELECT friend,AVG(loyalty), AVG(courtesy), AVG(stability), AVG(attitude)
FROM friendgrade
WHERE friend IN (SELECT friend FROM friendgrade WHERE name='$find')
GROUP BY friend ";
$result=mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$userinfo = mysql_fetch_array($result);
print_r($userinfo);
}
else
{
echo "Invalid username"; // or whatever
}
}//end isset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Enter a random number</td>
<td>
<input name="randomnumber" type="text" id="randomnumber" /></td>
</tr>
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
<table width="335" border="1">
<tr>
<td width="325"> search friends
<input type="text" name="find" id="find" /> </td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
01-20-2010, 08:32 AM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
ok now its getting complicated, the final stretch, outputting the average grade overall, and outputting the overall attribute grades. lol. im trying to get the average of the arrays elements and output, "unique" has an average grade of "A" or something similar. please help if anyone has time, thanks. derek here it is (eventually i want to put the output into a table)
i keep getting this message at the top even though i dont think im echoing the array
Array ( - => unique [friend] => unique [1] => 2.3333 [AVG(loyalty)] => 2.3333 [2] => 2.3333 [AVG(courtesy)] => 2.3333 [3] => 2.3333 [AVG(stability)] => 2.3333 [4] => 2.3333 [AVG(attitude)] => 2.3333 )
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field1 = mysql_real_escape_string($field1);
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field1 = $_POST['randomnumber'];
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$find = $_POST['find'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
if(isset($_POST['Submit'])){
if ($average <= 1) {
$grade = "F";
echo "You have given $field2 a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "You have given $field2 a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "You have given $field2 a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "You have given $field2 a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "You have given $field2 a grade of <strong>A.</strong> ";
}
///you need to know all the vote values, then divide them by the total, to get average
///where do i store all the vote values? you have to store all the votes for each specific friend. but how? then i have to be able to update the grade based on all the averages.
/*Quick suggestion without too much thought, would be to have all the "grades" in a separate table and join them on the userid.
id - numeric - [record number]
uid - numeric [FK for user table]
type - char - [code to identify which grade]
value - numeric - [value for the grading]
vid - numeric - [id of voter]
that covers another of your questions. How to stop fake voting.*/
mysql_query("INSERT INTO friendgrade (randomnumber, grade, zip, friend, courtesy,stability,loyalty,attitude) VALUES('$field1','$grade' , '$field3','$field2', $field4 , '$field5',' $field6', '$field7' ) ON DUPLICATE KEY UPDATE courtesy = courtesy + $field4, stability = stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7");
}//end isset
//output the friend's row into an array and average all rows of his attributes.
if(isset($_POST['submit'])){
$query="SELECT friend,AVG(loyalty), AVG(courtesy), AVG(stability), AVG(attitude)
FROM friendgrade
WHERE friend IN (SELECT friend FROM friendgrade WHERE friend='$find')
GROUP BY friend ";
$result=mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$userinfo = mysql_fetch_array($result); //put friends row into an array $userinfo
$final_grade= $userinfo[1]+$userinfo[2]+$userinfo[3]+$userinfo[4]/4; //compute final grade
//average the SQL output friend's total grade for all users input
if ($final_grade <= 1) {
echo "$field2 has an average grade of <strong>F.</strong> ";
} else if ($final_grade > 1 && $average <= 2) {
echo "$field2 has an average grade of <strong>D.</strong> ";
} else if ($final_grade > 2 && $average <= 3) {
echo "$field2 has an average grade of <strong>C.</strong> ";
} else if ($final_grade > 3 && $average <= 4) {
echo "$field2 has an average grade of <strong>B.</strong> ";
} else if ($final_grade > 4 && $average <= 5) {
echo "$field2 has an average grade of <strong>A.</strong> ";
}
}//end if
else
{
echo "Friend not found"; //add this after found to get errors or see whats happening $query"
}
}//end isset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Enter a random number</td>
<td>
<input name="randomnumber" type="text" id="randomnumber" /></td>
</tr>
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
<form id="form2" name="form2" method="post" action="">
<table width="335" border="1">
<tr>
<td width="325"> search friends
<input type="text" name="find" id="find" /> </td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
01-20-2010, 09:33 AM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 611
|
ok here is the latest if anyone can help please.
i put for friend "izzy" a grade of A and F, and when i search friends it is supposed to say,
"izzy has an average grade of C"
but it outputs nothing
Code:
<?php
include("connect1.php");
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$field1 = mysql_real_escape_string($field1);
$field2 = mysql_real_escape_string($field2);
$field3 = mysql_real_escape_string($field3);
/// query db and loop through rows example
$field1 = $_POST['randomnumber'];
$field2 = $_POST['friend'];
$field3 = $_POST['zip'];
$field4 = $_POST['grade1'];
$field5 = $_POST['grade2'];
$field6 = $_POST['grade3'];
$field7 = $_POST['grade4'];
$find = $_POST['find'];
$field4 = (int)$field4;
$field5 = (int)$field5;
$field6 = (int)$field6;
$field7 = (int)$field7;
$total = 4;
$sum = $field4 + $field5 + $field6 + $field7;
$average = $sum/$total;
if(isset($_POST['Submit'])){
if ($average <= 1) {
$grade = "F";
echo "You have given $field2 a grade of <strong>F.</strong> ";
} else if ($average > 1 && $average <= 2) {
$grade = "D";
echo "You have given $field2 a grade of <strong>D.</strong> ";
} else if ($average > 2 && $average <= 3) {
$grade = "C";
echo "You have given $field2 a grade of <strong>C.</strong> ";
} else if ($average > 3 && $average <= 4) {
$grade = "B";
echo "You have given $field2 a grade of <strong>B.</strong> ";
} else if ($average > 4 && $average <= 5) {
$grade = "A";
echo "You have given $field2 a grade of <strong>A.</strong> ";
}
///you need to know all the vote values, then divide them by the total, to get average
///where do i store all the vote values? you have to store all the votes for each specific friend. but how? then i have to be able to update the grade based on all the averages.
/*Quick suggestion without too much thought, would be to have all the "grades" in a separate table and join them on the userid.
id - numeric - [record number]
uid - numeric [FK for user table]
type - char - [code to identify which grade]
value - numeric - [value for the grading]
vid - numeric - [id of voter]
that covers another of your questions. How to stop fake voting.*/
mysql_query("INSERT INTO friendgrade (randomnumber, grade, zip, friend, courtesy,stability,loyalty,attitude) VALUES('$field1','$grade' , '$field3','$field2', $field4 , '$field5',' $field6', '$field7' ) ON DUPLICATE KEY UPDATE courtesy = courtesy + $field4, stability = stability + $field5, loyalty = loyalty + $field6, attitude = attitude + $field7");
}//end isset
//output the friend's row into an array and average all rows of his attributes.
if(isset($_POST['submit'])){
$query="SELECT friend,AVG(loyalty), AVG(courtesy), AVG(stability), AVG(attitude)
FROM friendgrade
WHERE friend IN (SELECT friend FROM friendgrade WHERE friend='$find')
GROUP BY friend ";
$result=mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$userinfo = mysql_fetch_array($result); //put friends row into an array $userinfo
$final_grade= $userinfo[1]+$userinfo[2]+$userinfo[3]+$userinfo[4]/4; //compute final grade
//average the SQL output friend's total grade for all users input
if ($final_grade <= 1) {
echo "$final_grade[0] has an average grade of <strong>F.</strong> ";
} else if ($final_grade > 1 && $final_grade <= 2) {
echo "$final_grade[0] has an average grade of <strong>D.</strong> ";
} else if ($final_grade > 2 && $final_grade <= 3) {
echo "$final_grade[0] has an average grade of <strong>C.</strong> ";
} else if ($final_grade > 3 && $final_grade <= 4) {
echo "$final_grade[0] has an average grade of <strong>B.</strong> ";
} else if ($final_grade > 4 && $final_grade <= 5) {
echo "$final_grade[0] has an average grade of <strong>A.</strong> ";
}
}//end if
else
{
echo "Friend not found"; //add this after found to get errors or see whats happening $query"
}
}//end isset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Statement</title>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #0066FF}
.style3 {color: #0000CC}
.style4 {color: #993399}
-->
</style>
</head>
<body>
</p>
<div align="center">WELCOME TO THE FRIENDGRADER</div>
<p>Please enter a friend, their zip code, and rate them with the following criteria.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="">
<table border="0">
<tr>
<td>Enter a random number</td>
<td>
<input name="randomnumber" type="text" id="randomnumber" /></td>
</tr>
<tr>
<td>Friend</td>
<td>
<input name="friend" type="text" id="friend" /></td>
</tr>
<tr>
<td>zip code</td>
<td>
<input name="zip" type="text" id="zip" />
</td>
</tr>
<tr>
<td>courtesy</td>
<td><table>
<tr>
<td>
<input type="radio" name="grade1" value="1" id="RadioGroup1_0" />
very poor
<input type="radio" name="grade1" value="2" id="RadioGroup1_1" />
poor
<input type="radio" name="grade1" value="3" id="RadioGroup1_2" />
ok
<input type="radio" name="grade1" value="4" id="RadioGroup1_3" />
good
<input type="radio" name="grade1" value="5" id="RadioGroup1_4" />
excellent
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>stability</td>
<td><input type="radio" name="grade2" id="very_poor3" value="1" />
very poor
<input type="radio" name="grade2" id="poor3" value="2" />
poor
<input type="radio" name="grade2" id="ok3" value="3" />
ok
<input type="radio" name="grade2" id="good3" value="4" />
good
<input type="radio" name="grade2" id="excellent3" value="5" />
excellent</td>
</tr>
<tr>
<td>loyalty</td>
<td><input type="radio" name="grade3" id="very_poor4" value="1" />
very poor
<input type="radio" name="grade3" id="poor4" value="2" />
poor
<input type="radio" name="grade3" id="ok4" value="3" />
ok
<input type="radio" name="grade3" id="good4" value="4" />
good
<input type="radio" name="grade3" id="excellent4" value="5" />
excellent</td>
</tr>
<tr>
<td>attitude</td>
<td><input type="radio" name="grade4" id="very_poor5" value="1" />
very poor
<input type="radio" name="grade4" id="poor5" value="2" />
poor
<input type="radio" name="grade4" id="ok5" value="3" />
ok
<input type="radio" name="grade4" id="good5" value="4" />
good
<input type="radio" name="grade4" id="excellent5" value="5" />
excellent</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
<form id="form2" name="form2" method="post" action="">
<table width="335" border="1">
<tr>
<td width="325"> search friends
<input type="text" name="find" id="find" /> </td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
01-21-2010, 10:34 PM
|
Re: incrementing by number a row with a specific user name in a table row
|
Posts: 1
Name: Pheobe Halls
|
gosh!! how do you remember all of this.
|
|
|
|
|
« Reply to incrementing by number a row with a specific user name in a table row
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|