i am working on building an intranet site for our company. basically, it is a time sheet for our hourly employees.
so far everything seems to be working ok except that i am getting extra rows inserted into my database. the data is all either null or zero on these rows. i have looked through my code and cant find my mistake. i also searched these forums, and so far havent found any posts with the same errors.
the following is a snippet of my code that writes to the database. please forgive it's sloppiness, i am learning on the fly.
for ($n=0;$n<=3;$n+=1){
if ($employee[$n]!="none"){
echo $employee[$n]." - ";
echo $hours[$n]." hours <br>";
echo "Crew Chief: ".$chief[$n]."<br>";
$cchief=$chief[$n];
$employee_insert=$employee[$n];
$hours_insert=$hours[$n];
$connection = mysql_connect($host,$user,$password)
or die ("Could not connect to server");
$db = mysql_select_db($database,$connection)
or die ("Could not select database");
$query = "INSERT INTO survey (input_date,projectname,projectnumber,employee,hours,code,codedescription,description,weather,day,crewchief)
VALUES('$insert_date','$job[1]','$job[0]','$employee_insert','$hours_insert','$code','$code_description','$description','$weather','$day','$cchief')";
$result = mysql_query($query)
or die ("Could not execute query");
mysql_close($connection);
}
}