i have problem in my code
i wanna to check if the teacher rate the course or or not
if he rate not allow to rate again
this is my code
<title>Subject Matrix</title>
<link rel="stylesheet" type="text/css"
href="styles.css"/>
<?php
session_start();
$teacher=$_SESSION['user'];
$conter=0;
foreach($_POST as $key=>$value)
{
//and $value<>""
if($key<>'teacher' )
{
include('con-db.php');
$sql="insert into sub_matrix(code_Name,Teach_rate,id_Num)values('$key','$value',$teacher)";
$query=mysql_query($sql);
$conter++;
}
}
echo"<br>";
echo"<br>";
echo"<div align='center'>";
echo "<font size = '5' color='#5A3A0B'>You rate ".$conter." course<br/></font>";
echo"<br>";
echo "<a href='Subject-matrix.php'>Return</a>";
?>
and i add the function for check like this
<?php
session_start();
$teacher=$_SESSION['user'];
include('con-db.php');
$conter=0;
foreach($_POST as $key=>$value)
{
//and $value<>""
if($key<>'teacher' )
{
if(Isselect($_REQUEST['id_Num'],$_REQUEST['code_Name']))
{
echo "the teacher ".$_REQUEST['id_Num']. " is rated already";
}
else
{
$sql="insert into sub_matrix(code_Name,Teach_rate,id_Num)values('$key','$value',$teacher)";
$query=mysql_query($sql);
$conter++;
}
}
}
echo"<br>";
echo"<br>";
echo"<div align='center'>";
echo "<font size = '5' color='#5A3A0B'>You rate ".$conter." course<br/></font>";
echo"<br>";
echo "<a href='Subject-matrix.php'>Return</a>";
function Isselect($teacher,$key)
{
$sql="select * from sub_matrix where id_Num =".$teacher." and code_Name='".$key."'";
$query=mysql_query($sql);
$num=mysql_num_rows($query);
if ($num>0)
return true;
else
return false;
}
?>
the error are undefined index
Notice: Undefined index: id_Num
Notice: Undefined index: code_Name in
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
i try to solve but i can't
can you help me plz ?

New Topic/Question
Reply




MultiQuote



|