SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Please help with student's marks report

    Hello every body
    Please help me to write this code
    i want to display table like this
    http://imageshack.us/photo/my-images/443/reportw.jpg/

    Generated from three database tables depends on student ID

    http://img51.imageshack.us/img51/1272/tablesh.jpg

    So i want to display this table without any fixed value of exams or subjects .. just i want the idea of looping

    And is this the best way to insert the students marks?? coz by this way if i have 5000 student and 10 subjects and 12 exam in year .. i will have mor than 500.000 record in table Stu_Marks

    sorry for my english language

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,398
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by hawkeye000 View Post
    Please help me to write this code
    Welcome to the SP forums.
    If you post the code you have so far, and then ask a specific question about something that is blocking you, then I'm sure someone will be willing to point you in the right direction.

    And is this the best way to insert the students marks?? coz by this way if i have 5000 student and 10 subjects and 12 exam in year .. i will have mor than 500.000 record in table Stu_Marks
    Yes that's the best way. You don't have to worry about performance if you create the right indexes.

  3. #3
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello dear
    i don't know where can i start .. if i have array for exams and array for subjects and values depends on exam_id and subj_id
    how can i use exam_id from the first loop to put it in the second one then display the grades ?
    i will try to write a code to explain more

  4. #4
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you please create this report from database tables ?? coz i tried to write sevral arrays and loops and i failed

  5. #5
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Please start by posting what you tried and we can see if any of your approaches work. We will not do this for you, but are glad to help, so please post your code.

    Steve
    ictus==""

  6. #6
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello again
    i did it by this way and i am not sure if it correct or no


    PHP Code:
    <?


    $con 
    mysql_connect("localhost","root","123");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }
    mysql_select_db("test"$con);


    ////////////////////////


        
        ///////////////// Select the exams and put it in array 
        
    $ex mysql_query("SELECT * FROM exams"); 
        
    $dc=1;
    while (
    $rowexmysql_fetch_array($ex)){
        
    $exn[$dc]=$rowex['Exam_Title'];
        
    $exid[$dc]=$rowex['Exam_ID'];
    $dc++;
        }
        
        
        
    /////////////////////////// Select the subjects and put it in array 
        
    $sj mysql_query("SELECT * FROM subjects"); 
        
    $dsj=1;
    while (
    $rowsjmysql_fetch_array($sj)){
        
    $sjn[$dsj]=$rowsj['Subj_Title'];
    $sjid[$dsj]=$rowsj['Subj_ID'];
    $dsj++;
        }
        
        
    ///////////////////Select the student marks and put it in array with subject id and exam id
        
        
    $result mysql_query("SELECT * FROM stu_grade"); 
    while (
    $rowmysql_fetch_array($result)){
        
    $arr[$row['Subj_ID']][$row['Exam_ID']]=$row['Grade'];

        }
        
    /////////////////////// count the exams and the subjects to draw the table
         
    $exc=count($exn);
         
    $sjc=count($sjn);
         
    ?>
         
    <table width="400" border="1">
      <tr>
        
       
         
         <?
    ///////// display subjects in table rows
    for ($d=0;$d<=$sjc;$d++){
        
        if (
    $d==0){
        echo 
    '<td>-</td>';
        }else{
        echo 
    ' <tr><td>'.$sjn[$d].'</td>';
        }
    ///////// display exams in table head tds 

    for ($p=1;$p<=$exc;$p++){
        if (
    $d==0){
        echo 
    '<td> '.$exn[$p].'</td>';
        }else{
    ?>
     <td>
     
     <?=$arr[$sjid[$d]][$exid[$p]]?>
      
     </td>
          <?}
          }
    }
    ?>
        
      </table>

  7. #7
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ??

  8. #8
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Hi,

    Why don't you know if this is correct or not? Have you ran it? Do you get any errors? Are you asking just if this is a good way to do this?
    ictus==""

  9. #9
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello dear

    Yes i asking just if this is a good way to do this.. it is working good but i hope to know if it is the best way or not


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •