School Online Result System

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thefarhan
Forum Newbie
Posts: 5
Joined: Tue Dec 22, 2009 7:02 am

School Online Result System

Post by thefarhan »

i have 2 tables in MySQL: STUDENT & RESULT.
Student table has following columns: Student_ID, Name, Registration # & Roll Number.

Result table has following columns:Result_ID, Roll Number, Year, Term, Subject, result

Refer to the attached image, 1st of all i select Year, Term, Subject from drop down menus on the top, by pressing the "Get Student" I will get Students from STUDENT table on as shown in the attached image, Now by pressing Submit Form Button on the bottom of the page, result will be added in the Year, Term, Subject & result columns of the RESULT table. This process will be repeated many times but with different Year, Terms & subjects.

each time I want to get(by pressing Get Student Button) only those students from STUDENT table whose result has not already been entered for a particular year, term (each year has two terms i.e Mid & Final) & subject in the RESULT table.

For example i have 10 students in the STUDENT table. I have already entered result for 2008, Mid term, Subject Accounting, of students from roll number 1 to 5 in the RESULT table. Now, if i again select Year 2008, Term Mid & Subject Accounting from the drop down menus & press Get Student Button, then students from roll number 6 to 10 should appear on the page as Students from Roll Number 1 to 5 have already been entered.

Right now i m using this code which is not working.

Code: Select all

<?php
session_start();
 
if($_SESSION['username']=="")
{
    header("location:userlogin.php");
}
 
$struser=$_SESSION['username'];
include("include/DBConnect.php"); 
?>
 
<html>
 
<head>
 
<title>Result Input Page</title>
 
<link href="SP.css" rel="stylesheet" type="text/css">
  
</head>
 
<body>
 
<div Class="main_user">
<h1> Result Input Page  </h1>
 
<form id="phpUpdateResult" action="include/phpEnterResult.php" method="post" name="phpUpdateResult" ">
<table border="1">
  <tr style="text-align:center;">
    <td colspan="7">
    <select id="listYear" name="listYear" onChange="LoadPage()">
      <option value="Select">Year</option>
      <?php
        $strYear="Select * from year";
        $resultYear=mysql_query($strYear);
        while($rowYear=mysql_fetch_array($resultYear))
        {
            if($_POST['listYear']==$rowYear['Year_ID'])
            {
    ?>
                <option value="<?php echo($rowYear['Year_ID']);?>" selected="selected"><?php echo($rowYear['Year']);?></option>
        <?php
            }
            else
            {
        ?>
      <option value="<?php echo($rowYear['Year_ID']);?>"><?php echo($rowYear['Year']);?></option>
      <?php
            }
        }
        ?>
    </select>
      <select id="listTerm" name="listTerm" >
        <option value="Select">Term</option>
        <?php
        $strTerm="Select * from term";
        $resultTerm=mysql_query($strTerm);
        while($rowTerm=mysql_fetch_array($resultTerm))
        {
    ?>
        <option value="<?php echo($rowTerm['Term_ID']);?>"><?php echo($rowTerm['Term']);?></option>
        <?php
        }
        ?>
      </select>
      <select id="listSubject" name="listSubject" >
        <option value="Select">Subject</option>
        <?php
        $strSubject="Select * from subject";
        $resultSubject=mysql_query($strSubject);
        while($rowSubject=mysql_fetch_array($resultSubject))
        {
    ?>
        <option value="<?php echo($rowSubject['Subject_ID']);?>"><?php echo($rowSubject['Subject']);?></option>
        <?php
        }
        ?>
      </select></td>
    </tr>
  <tr bgcolor="#CCCCCC" bordercolor="#000000" align="center">
    <td><strong>ID</strong></td>
    <td><strong>Student</strong></td>
    <td><strong>Registration # </strong></td>
    <td><strong>Roll # </strong></td>
    <td><strong>Marks</strong></td>
  </tr>
    <?php 
        
        $strStudent="SELECT * FROM student WHERE AddedBy='".$struser."'";
        $resultStudent=mysql_query($strStudent);
        while($rowStudent=mysql_fetch_array($resultStudent))
        {
        ?>
    <tr>
        <td><input type="hidden" name="txtStudent_ID[]" id="txtStudent_ID[]" value"<?php echo($rowStudent['Student_ID']); ?>"/><?php echo($rowStudent['Student_ID']); ?></td>
        <td><input type="hidden" name="txtStudent[]" id="txtStudent[]" value"<?php echo($rowStudent['Student']); ?>"/><?php echo($rowStudent['Student']); ?></td>
        <td><input type="hidden" name="txtRegNumber[]" id="txtRegNumber[]" value"<?php echo($rowStudent['RegNumber']); ?>"/><?php echo($rowStudent['RegNumber']); ?></td>
        <td><input type="hidden" name="txtRollNumber[]" id="txtRollNumber[]" value"<?php echo($rowStudent['RollNumber']); ?>"/><?php echo($rowStudent['RollNumber']); ?></td>
        <td><input type="text" name="txtObtained[]" id="txtObtained[]"/> </td>
        
    </tr>
    <?php }
    }
     ?>
    <tr style="text-align:center;">
      <td colspan="7"><input name="Submit" type="submit" value="     Submit  Form     "/></td>
    </tr>   
</table>
    
</form>
 
 
</div>
 
</body>
</html>
Attachments
Result input Page.jpg
Result input Page.jpg (171.44 KiB) Viewed 292 times
Post Reply