saya bt pasal coursework system..
then cam lecturer nak add maks sekali byk ye..
saya dah try tapi data just insert yg last row je..
plz tolong..saya guna oop pakai language php...
saya pastekan skali coding ye..
quiz1table.php
(yg ni saya retrievekan bape ramai student dr db)
Code:
<?php
/////////////////////////// DRAWTABLE FUNCTION START ////////////////////////////
function drawquiz1table() {
$db = new MySQL (HOST, USER, PASS, DATABASE);
/* $sqlview = $db->query('select * from studydetails where lecturerID="'.$_COOKIE['user'].'" order by studentID'); */
/* $sqlview = $db->query('select attendance.name,studydetails.id,studydetails.studentName,studydetails.studentID,studydetails.courseID
from attendance, studydetails
where attendance.courseID ="'.$_GET['courseID'].'"
and studydetails.courseID ="'.$_GET['courseID'].'"
and studydetails.lecturerID="'.$_COOKIE['user'].'" order by studentID'); */
$sqlview = $db->query ('select attendance.name,attendance.att_id,attendance.percentage,studydetails.studentName,studydetails.studentID,studydetails.courseID,
studydetails.id
from attendance, studydetails
where attendance.att_id = "'.$_GET['att_id'].'"
and studydetails.courseID ="'.$_GET['courseID'].'"
and studydetails.lecturerID="'.$_COOKIE['user'].'" order by studentID');
$i=1;
?>
<table border="3" cellspacing="0" cellpadding="5">
<tr>
<td class="header" bgcolor="#999999"><font color="#333333"><strong>Current Assesment : <?php echo $_GET["attname"]; ?></strong></font></td>
</tr>
</table>
<?php
if($sqlview->size() != 0) {
?>
<table width="" border="0">
<tr>
<td class="filetitle" width="41"><center>No</center></td>
<td class="filetitle" width="113"><center>StudentID</center></td>
<td class="filetitle" width="200"><center>Name</center></td>
<td class="filetitle" width="200"><center>courseID</center></td>
<td class="filetitle" width="200"><center>Marks</center></td>
</tr>
<?php
while($view = $sqlview->fetch()) {
?>
<form name="insert_marks" action="addmarks2.php?attname=<?php echo $_GET["attname"]; ?>&att_id=<?php echo $_GET['att_id']; ?>&percentage=<?php echo $_GET['percentage']; ?>" method="post">
<tr>
<td class="filelist" valign="middle">
<center><input name="noid" type="text" value="<?php echo $i; ?>" size="2"></center>
<center><?php /* echo $i; */ ?></center>
</td>
<td class="filelist" valign="middle">
<center><input name="studentID" type="text" value="<?php echo $view['studentID']; ?>" size="5"></center>
</td>
<td class="filelist" valign="middle">
<center><input name="studentName" type="text" value="<?php echo $view['studentName']; ?>" size="20"></center>
<center><?php /* echo $view['studentName']; */?></center>
</td>
<td class="filelist" valign="middle">
<center><input name="courseID" type="text" value="<?php echo $view['courseID']; ?>" size="5"></center>
<center><?php /* echo $view['courseID']; */?></center>
</td>
<td class="filelist" valign="middle">
<center>
<input name="txt_marks" type="text" value="" size="3" maxlength="3">
<input name="id" type="hidden" value="<?php echo $view['id']; ?>"/>
<input name="att_id" type="hidden" value="<?php echo $_GET["att_id"]; ?>"/>
</center>
</td>
</tr>
<?php
$i++;
}
?>
<tr>
<input name="att_id" type="hidden" value="<?php echo $_GET["att_id"]; ?>"/>
<td class="filelist" colspan="5" align="right"> <input type="submit" name="btn_addmarks" value="addmarks">
</td>
</tr>
</form>
</table>
<?php
}
else {
echo "No student found<br><br>";
?>
<?php
}
}
?>
yang bawah ni page dmana insert mark d process..
addmarks2.php
<?php
if(isset($_COOKIE['user'])) {
include('core/config.php');
include('lib/MySQL.php');
include('cu.php');
include('drawquiz1table.php');
$db = new MySQL (HOST, USER, PASS, DATABASE);
?>
<?php include('template/header.html'); ?>
<link href="style/css_table.css" rel="stylesheet" type="text/css" />
<div id="nav">
<center>
<?php include('menu_sign.php'); ?>
</center>
</div>
<div id="body">
<?php
echo '<b>Welcome';
if (isset($_COOKIE['firstname'])) {
echo " : {$_COOKIE['firstname']}!";
}
echo '</b>';
?>
<div id="bodysign-left">
<br>
<?php
include('ass_menu.php');
?>
</div>
<div id="bodysign-center">
<br>
<?php
if(!isset($_POST['btn_addmarks'])) {
$db = new MySQL('localhost','root','','scms1');
$duplicate=0;
drawquiz1table();
}
elseif(isset($_POST['btn_addmarks']) and $_POST['att_id'] != "") {
/* $select_file = $db->query('select * from marks where courseID="'.$_POST['courseID'].'" and att_id="'.$_POST['att_id'].'"'); */
$select_file = $db->query('select * from marks where studentID="'.$_POST['studentID'].'" and att_id="'.$_POST['att_id'].'"');
$salted='unable';
while($list_file = $select_file->fetch()) {
/* if($list_file['att_id']['courseID'] == addslashes($_POST['att_id']['courseID'] )) { */
if($list_file['att_id']['studentID'] == addslashes($_POST['att_id']['studentID'] )) {
$duplicate = 1;
print_r($size_array);
?>
<meta HTTP-EQUIV="Refresh" CONTENT="1; URL=view_marks.php?courseID=<?php echo $_POST['courseID']; ?>">
<?php
}
echo "<center><font color=\"#CC0000\">Assesment already exist<br></font></center>";
}
if ($duplicate != 1) {
/* $select_file2 = $db->query('select * from studydetails where id="'.$_POST['id'].'"');
while($list_file2 = $select_file2->fetch()) { */
$insertcat = $db->query('insert into marks set
att_id="'.$_POST['att_id'].'",
id="'.$_POST['noid'].'",
lecturerID="'.$_COOKIE['user'].'",
studentID="'.$_POST['studentID'].'",
studentName="'.$_POST['studentName'].'",
courseID="'.$_POST['courseID'].'",
marks="'.$_POST['txt_marks'].'",
name="'.$_GET['attname'].'"');
print_r($list_file);
}
?>
<meta HTTP-EQUIV="Refresh" CONTENT="1; URL=list5.php?attname=<?php echo $_GET['attname']; ?>&courseID=<?php echo $_POST['courseID']; ?>&percentage=<?php echo $_GET['percentage']; ?>">
<center>
Marks Added.
</center>
<?php
/*
} */
?>
</center>
<br>
</div>
<div id="bodysign-right">
</div>
<div class="clear"></div>
</div>
<?php include('template/footer.html'); ?>
</body>
</html>
<?php
}
else {
?>
<font size="+1">Page expired. Please <a href="index.php">sign in</a> again.</font>
<?php
}
}
?>
hope ada yg bole tolong saya..
