toleen 0 Newbie Poster

hello

i am a very biggner in php but i have to do a homework about student regstration module

there is 4 groups and 32 student ,each groupe should have 8 students

when a student would be register in a groupe
should i check if he is alredy exist in the database, if he so should i display a page and tell him u r already exist,do u want to change your groupe and display the form to select a groupe from it

and if he not exist in database but select a groupe is full, a page should be displayed with the groupes are not fully

how should i do this???????????????????????

i am trying to solve it but i cant i am little in php

hope u help me


i write this code

<html>
<head>
<?php include_once("Connection.php");
?>
</head>
<body>
<?php ConnectToDatabase ();

if (isset($_POST)){
if (empty($_POST)){
echo 'please fill all fields';
}
else {
$name=$_POST;
$id=$_POST;
$email=$_POST;
$grp=$_GET;
for($i=0;$i<4;$i++)
if($grp)
$query = "select groupeNum from groupes
where time=$grp;

$query1 ="INSERT INTO studentsgroup VALUES ('$name', '$id', '$email', 'groupeNum')";
$result = mysql_query($query1,$student);

$checkstu = "SELECT count(*) FROM studentsgroup
WHERE SID=$id;

$check = mysql_query($checkstu, $student);
$result1 = mysql_fetch_row($check);
$result1 = $result1;

if($result1 >0) {
//here shold be a link to another page includes something like:
//you are already register do you want to change your group?
//and there are to buttons when clik yes should be displayed all groups and
//select from thier and also check if this groupe is full or not

}
else {
$insertstudent="INSERT INTO studentsgroup VALUES ('$name', '$id', '$email', 'groupeNum')";
$write = mysql_query($insertstudent,$student);

?>


and the database is student
have 2 tables
groupes(groupNum, lecturer,password,time)
studentsgroup(groupNum,SID,groupName,email)