Hi,
Here is the DBStudent_Course
<?php
//Save as DBStudent_Course.php
require("db_config.php");
class DBStudent_Course {
/* DB connection handle */
private $conn;
function insert_student_course($SID, $Cid, $grade, $comments) {
$esc_SID = mysql_real_escape_string($SID, $this->conn);
$esc_Cid = mysql_real_escape_string($Cid, $this->conn);
$esc_grade = mysql_real_escape_string($grade, $this->conn);
$esc_comments = mysql_real_escape_string($comments, $this->conn);
$sql = "INSERT INTO Student_Course(SID, Cid, grade, comments)
VALUES ('{$SID}','{$Cid}','{$esc_grade}', '{$esc_comments}')";
$result = mysql_query($sql, $this->conn);
if (!$result) {
die("SQL Insertion error: " . mysql_error());
} else {
$numofrows = mysql_affected_rows($this->conn);
return $numofrows;
}
}
function openDB() {
$this->conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$this->conn) {
die("SQL Connection error: " . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $this->conn);
if (!$db_selected) {
die("SQL Selection error: " . mysql_error());
}
}
function getResult($sql)
{
$result = mysql_query($sql, $this->conn);
if($result)
{
return $result;
}
else
{
die("SQL Retrieve Error: " . mysql_error());
}
}
function closeDB() {
mysql_close($this->conn);
}
function update_student_course($Sid,$Cid, $grade, $comment)
{
$esc_SID = mysql_real_escape_string($id, $this->conn);
$esc_grade = mysql_real_escape_string($grade, $this->conn);
$esc_comment = mysql_real_escape_string($comment, $this->conn);
$sql="update student_course set name ='{$esc_grade}' where id={$esc_SID}";
$result = mysql_query($sql, $this->conn);
if(!$result)
die("SQL Error: " . mysql_error());
else
{
$numofrows = mysql_affected_rows($this->conn);
return $numofrows;
}
}
}
?>