what's wrong in my codes?
this is my insert.php:
`<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="rommelbarrio"; // Mysql password
$db_name="system"; // Database name
$tbl_name="grades"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$course = $_POST["course"];
$semester = $_POST["semester"];
$year = $_POST["year"];
$id_no = $_POST["id_no"];
$result = $_POST["grades"];
// Insert data into mysql
if (count($result > 0))
{
$new = array();
foreach ($result as $key => $value)
{
$new[] = "('" . $course . "', '" . $semester . "', '" . $year . "', '" . $id_no . "', '" . $value["subject"] . "', '" . $value["descriptive_title"] . "', '" . $value["final_grades"] . "', '" . $value["remarks"] . "')";
}
if (count($new) > 0)
{
$query = mysql_query("INSERT INTO grades (course, semester, year, id_no, subject, descriptive_title, final_grades, remarks) VALUES". implode( ',', $new));
if ($query)
{
echo "SUCCESS";
}
else
{
echo "FAILED";
}
}
}
// close connection
mysql_close();
?>
then this is my form:
the database/table is mess with my php codes..:}hope you all understand..:}
my output plan is this:
id_no year semester course subject descriptive_title final_grades remarks
1200 first second com.sci vb visual basic 1.2 pass
1200 first second com.sci php php 1.2 pass
1200 first second com.sci .net net 1.2 pass
1200 first second com.sci java java prog. 1.2 pass
1200 first second com.sci c++ c. prog. 1.2 pass