PHP/ MYSQL Employee Evaluation

Ok so i’m a completely self taught noob, so i’m sorry if this is easy, but I’m having a difficult time figuring out how to create a employee evaluation with questions stored in a database. I’ve already created this, but hard coded everything which I think is incorrect. So let me first show you the table layout cause maybe something went wrong there.

Table Employee
Pk ID
FirstName
LastName

Table Department
Pk ID
Name

Table Question
Pk ID
QuestionText
FK DepartmentID

Table Answers
PK ID
FK QuestionID
FK EmployeeID
Answer

All questions are scale questions 1-10 ranking, i need to be able to sum total score at the end. Example how well does the employee communicate 1-10

Ok so if this is incorrect for the table layout please let me know. Assuming this is correct i’m running into a couple issues.

1 if this is correct, i will have 15 rows created (15 questions review) for each evaluation. Don’t know if this a problem.

2 Keeping in mind i’m a complete noob, my first thought was to output the question as such

select * from questions where department id = 1

which would display all the questions for department x. The problem I have if i do it this way how would i link the answer drop down list 1-10 to the question id so that when the form is submitted the question ID and answer are both saved to the answer table. Also it would have to create a new row for each answer, which i’m not sure if that is possible.

the way i originally created the evaluation was that i manually typed each question on the form and then the database had a separate column for question.

example
table answers
pk id
fk employeeid
q1
q2
q3
q4
q5
q6
etc…

The problem i ran into with this was that every time i added a department i had to go back and hard code everything and add columns to the database which i don’t think is correct.

any help would be much appreciated. being new if you could code an actual example it would be very helpful. it’s had for me to see sudo code and correctly convert it. once i have a working example i can usually expand it from there.

Thanks again.

Am I on the right path?

[php]<?php
$con = mysql_connect(“localhost”,“user”,“pass”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

mysql_select_db(“database”, $con);

$result = mysql_query("SELECT * FROM questions WHERE idDepartment = 1 ");

while($row = mysql_fetch_array($result))
echo ’

'.$row['idDepartment'].' ' .$row['questionText'].' 1 2 3 4 5 6 7 8 9 10
';

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service