[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

insert data to three tables using one html form

Asked by colin0292 in PHP and Databases, MySQL Server, PHP Scripting Language

hey
im using phpmyadmin (MyISAM  storage engine) and i have table called
prof_rating which includes
-comm_id
-prof_id   ======> this field should link to another table called prof
-rate
-comment

prof table includes
-prof_id
-prof_name
-dept
-school_id ======> this field should link to another table called school

school table includes
-school_id
-school_name
-state
__________________________________________________
my question here: in my html form where any user could add review,this means i have one form that inserted into three different tables, how should i write the insert statement??
 i try to insert data but got some error msg that says" Incorrect integer value: '' for column 'prof_id' at row 1"
also i have to check if the prof_name already exists then add the comment and rate.

i'm not sure if im doing it the right way coz of that msg besides my tables didn't get any data.
plz see the html form and php code

help plz
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
########HTML FORM#############
<form action="rate.php" method="post">
Professor name:
	<br>
<input type="text" name="prof_name">
	<br>
School/University:
	<br>
<input type="text" name="school_name">
	<br>
Department:
	<br> 
<input type="text" name="dept">
	<br>
rate 1-5:
<select name="rate">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
</select>
	<br><br>
Your comments:<BR>
<TEXTAREA NAME="comment" COLS=40 ROWS=6></TEXTAREA>
	<br><br>
	<input type="submit" value="Submit">
	<input type="reset" value="Reset">
</form>
 
______________________PHP __________________________________
<?php
include 'config.php';
include 'opendb.php';
/* Check all form inputs using check_input function */
$prof_name   = check_input($_POST['prof_name'], "hey you..... Enter professor name.");
$school_name = check_input($_POST['school_name'], "Enter your school name.");
$dept		 = check_input($_POST['dept'], "Enter the department.");
$rate		 = check_input($_POST['rate']);
$comment     = check_input($_POST['comment'], "Enter your comment.");
 
 
$RSCount = mysql_query("SELECT COUNT(*) AS TotalRecords FROM prof WHERE prof_name = '{$_POST['prof_name']}'");
$CountRow = mysql_fetch_object($RSCount);
if ($CountRow->TotalRecords > 0)
{
	$RSProf = mysql_query("SELECT prof_id FROM prof WHERE prof_name = '{$_POST['prof_name']}'");
	$ProfRow = mysql_fetch_object($RSProf);
	$ProfIDToUpdate = $ProfRow->prof_id;
 
	$updateQuery = "UPDATE prof_rating SET rating = '{$_POST['rate']}' WHERE prof_id = '{$ProfIDToUpdate}'";
	@mysql_query($updateQuery) or die(mysql_error());
 
	$updateQuery = "UPDATE prof SET dept = '{$_POST['dept']}', school_id = '{$_POST['school_name']}' WHERE prof_id = '{$ProfIDToUpdate}'";
	@mysql_query($updateQuery) or die(mysql_error());
}
else
{
	$data= "INSERT INTO prof VALUES ('', '{$_POST['school_name']}', '{$_POST['dept']}', '{$_POST['prof_name']}')";
	@mysql_query($data) or die(mysql_error());
	$prof_id = mysql_insert_id();
	
	$todata= "INSERT INTO prof_rating VALUES ('', '{$prof_id}', '{$_POST['rate']}', '{$_POST['comment']}')";
	@mysql_query($todata) or die(mysql_error());
}
 
echo "<TD valign='top'><br /><center><b>You successed!";
echo "<br>";
 
 
 
/* Functions we used */
function check_input($data, $problem='')
{
    $data = trim($data);
    $data = stripslashes($data);
    /*$data = htmlspecialchars($data);*/
    if ($problem && strlen($data) == 0)
    {
        show_error($problem);
    }
    return $data;
}
 
function show_error($myError)
{
?>
    <html>
    <body>
 
    <b>Please correct the following error:</b><br />
    <?php echo $myError; ?>
 
    </body>
    </html>
<?php
exit();
}
?>
[+][-]07/03/09 08:59 PM, ID: 24775665Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: PHP and Databases, MySQL Server, PHP Scripting Language
Sign Up Now!
Solution Provided By: cxr
Participating Experts: 1
Solution Grade: A
 
[+][-]07/03/09 05:04 PM, ID: 24774999Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 05:13 PM, ID: 24775028Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 06:06 PM, ID: 24775177Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 06:13 PM, ID: 24775201Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 06:22 PM, ID: 24775232Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 06:24 PM, ID: 24775241Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 06:40 PM, ID: 24775305Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 06:50 PM, ID: 24775335Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 06:57 PM, ID: 24775350Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 07:03 PM, ID: 24775363Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 07:12 PM, ID: 24775394Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 07:23 PM, ID: 24775426Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 07:45 PM, ID: 24775480Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 07:56 PM, ID: 24775505Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 08:07 PM, ID: 24775546Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 08:17 PM, ID: 24775585Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 08:17 PM, ID: 24775586Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 08:18 PM, ID: 24775589Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 08:22 PM, ID: 24775596Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 08:33 PM, ID: 24775623Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 08:35 PM, ID: 24775630Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 08:47 PM, ID: 24775657Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/03/09 08:53 PM, ID: 24775660Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/03/09 09:05 PM, ID: 24775672Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20090701_SELECT_ZONES