SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 54
  1. #26
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jay93 View Post
    okay, well i had another question, this form is going to be a little different, one that kind of self-updates anytime a new student registers...in other words, ideally, is there a way the form will automatically display all the names of students who have currently registered?? with a text field adjacent to the m where the teacher will enter their marks??
    Yep, that is doable. However, you may want to approach it differently, you may want to allow a page for teachers to create a class/subject, and assign students to that class/subject (as you don't want to show students that are not in that class).

    Quote Originally Posted by jay93 View Post
    2. And i m not sure whether this will be possible, but another thing i would have very much loved to be in the form is, just above the form there is a field where the teacher enters the name of a subject, (and this will automatically be inserted into the "users" table as a new column) so that anytime the students log in , they get to see all their subjects and their scores in each????
    If teachers create a class/subject and assign students to it, then this part just needs to show the students associated to the given class and allow the teacher to enter the marks.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  2. #27
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wait wai wait, 1 sec, i just had another idea, since in my case, the subjects are fixed, and each student takes all subjects... could we just make a table containing a column for the student id ("id") and a column each for each subject.....for instance let's assume the students take these subjects: Anatomy, Physiology, and Biochemistry... so we have a new table called "subjects" containing the columns "id", "anatomy., "physiology", and "biochemistry"....

    and then on the teachers form, there is a drop-down menu where the teacher will select the name of the subject, and enter the marks for all the students to be inserted into the "subjects" table , adjacent to their "id"s,,,how does that sound??

  3. #28
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    You could do that, or you could have a table called marks that has id, subject, mark as the columns and there would be an entry for each user, subject (from the drop down, and the value of the mark for that student in that subject.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  4. #29
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, err, i can do only some of that... ... well i think i have some idea on how to create the dropdown menu, but regarding the names of students from the "users" table being automatically printed together with a field for their marks, could you please help me with how to code for that?? and i guess the coding for both these two (dropdown and student list+mark field) will be in a template file right??

  5. #30
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Query the all students "SELECT * FROM users"
    Loop through them writing their name and a field to enter the mark that has the name "mark[<?php echo $row['id']; ?>]" where $row is the current row, and id is the id of the student.

    When the submit button is clicked, loop through the form fields
    PHP Code:
    foreach ($_POST['mark'] as $studentId => $value)
    {
      
    // run update query setting the mark for the subject to $value WHERE id = $studentId

    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  6. #31
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks... i ll try that tomorrow, it's 3 am here...and just one last question for today, the mail() function,i ve never used it before.... how do we use it in this context to inform all the users about the update?? (selecting each users email address from the "users" table)...

  7. #32
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi, im done quite much with my teacher form...i have got the form with the drop down menu, and the names of the students being printed out, and in fact when the teacher submits teh scores, my table for "marks" gets updated... the little problem i had was whenever i insert scores for a new subject, all the old data is wiped off... is there a way i could make this process a cumulative one??
    CAP.JPG

    and this is what i have for the update process in teacher.php

    Code:
             //After teacher has entered marks...........
             if ($_SERVER["REQUEST_METHOD"] == "POST")
          {
             if (empty($_POST['subject']))
             apologize("Please select a subject");
             
          // run update query setting the mark for the subject to $value WHERE id = $studentid
             foreach ($_POST['mark'] as $studentid => $value)
             {
             
              
               $result = query("UPDATE marks SET scores = ?, subject = ? WHERE studentid = $studentid", $value, $_POST['subject']);
               if( $result===false)
                 apologize("Could not update student scores");
             }
             
          }

  8. #33
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    There are a couple of ways, you could require them to enter an assignment name, that you would store as another column in your table (thus everything will be an insert), plus this gives the students the advantage of seeing the mark per assignment.

    The other option is to use a date/time entry, but personally, I'd go the assignment route
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  9. #34
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ""them" you mean the teachers??? because what i've got for my teacher_form.php is as follows, and they do specify the subject::
    Code:
    form action="teacher.php" method="post">
        <fieldset>
                <div class="control-group">
                <select name="subject" placeholder="Select subject">
                    <option value=''></option>
                    <option value="Anatomy">Anatomy</option>  
                    <option value="Physiology">Physiology</option>  
                    <option value="Biochemistry">Biochemistry</option>  
                    <option value="Genetics">Genetics</option>  
                    <option value="Histology">Histology</option> 
                    <option value="Molecular Biology">Molecular Biology</option> 
                    <option value="Pathophysiology">Pathophysiology</option> 
                    <option value="Parasitology">Parasitology</option> 
                    <option value="Immunology">Immunology</option> 
                    <option value="Pathology">Pathology</option> 
                    <option value="Diagnostics">Diagnostics</option> 
                    <option value="Surgery">Surgery</option> 
                    <option value="Medical Statistics">Medical Statistics</option> 
                    <option value="Gynaecology">Gynaecology</option> 
                    <option value="Forensics">Forensics</option> 
                    <option value="Internal Medicine">Internal Medicine</option> 
                    <option value="Opthalmology">Opthalmology</option> 
                    <option value="Epidemiology">Epidemiology</option> 
                    <option value="Obstetrics">Obstetrics</option> 
                    <option value="Medical Ethics">Medical Ethics</option> 
                </select>
            </div>
            <p class="lead">ENTER STUDENT MARKS</p>
             <div class="control-group">
                 <?php               
    	                foreach ($rows as $row)	{ ?>
                           
                           <li><?php echo $row['name']; ?></li> 
                           <input name= "mark[<?php echo $row['id']; ?>]" placeholder="Marks" type="text"/>
                              
                       <?php } ?>   
            </div>
            
            <div class="control-group">
                <button type="submit" class="btn">SUBMIT SCORES</button>
            </div>
        </fieldset>
    </form>
    <div>
        or <a href="logout.php">log out</a>
    </div>

  10. #35
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Yes, I understand you allow them to specify a subject, but I thought the problem was, when they enter another mark for the subject, it was overwriting the previous mark for that subject? The question becomes, are you trying to allow teachers to enter marks for a given subject per assignment, per month/quarter/semester? If you want to store multiple marks per subject, you need to identify when it is applicable for a new mark to exist.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  11. #36
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually, not really,, what i meant was if as a teacher i entered the marks of only one subject say anatomy, it will be fine..but next, if i wanted to give the marks of another subject say (physiology, NOT A DIFFERENT SET OF MARKS FOR ANATOMY), all the anatomy marks will be oveerwritten with physiology mmarks, and even the"subject" column in my "marks" table shown above, in that table all "anatomy" changes to physiology...

  12. #37
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and your question about per semester, per month, week, etc... actually what i have in mind is that the teacher is going to insert marks only once for any subject...

  13. #38
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jay93 View Post
    actually, not really,, what i meant was if as a teacher i entered the marks of only one subject say anatomy, it will be fine..but next, if i wanted to give the marks of another subject say (physiology, NOT A DIFFERENT SET OF MARKS FOR ANATOMY), all the anatomy marks will be oveerwritten with physiology mmarks, and even the"subject" column in my "marks" table shown above, in that table all "anatomy" changes to physiology...
    Ah, okay. Good I was misunderstanding the question

    Okay, so the problem lies with this code:
    PHP Code:
             //After teacher has entered marks...........
             
    if ($_SERVER["REQUEST_METHOD"] == "POST")
          {
             if (empty(
    $_POST['subject']))
             
    apologize("Please select a subject");
             
          
    // run update query setting the mark for the subject to $value WHERE id = $studentid
             
    foreach ($_POST['mark'] as $studentid => $value)
             {
             
              
               
    $result query("UPDATE marks SET scores = ?, subject = ? WHERE studentid = $studentid"$value$_POST['subject']);
               if( 
    $result===false)
                 
    apologize("Could not update student scores");
             }
             
          } 
    The code regardless of what subject is selected is updating EVERY entry in marks for each studentid.
    What you want to do, is only update the mark for each student and subject (subject becomes part of the where clause)

    PHP Code:
             //After teacher has entered marks...........
             
    if ($_SERVER["REQUEST_METHOD"] == "POST")
          {
             if (empty(
    $_POST['subject']))
             
    apologize("Please select a subject");
             
          
    // run update query setting the mark for the subject to $value 
             
    foreach ($_POST['mark'] as $studentid => $value)
             {
               
    $subjectExistsForStudent query("SELECT scores FROM marks WHERE studentid = ? AND subject = ?"$studentid$_POST['subject']);
               if (
    $subjectExistsForStudent === false// check if the subject is already in the table, if it isn't INSERT it, otherwise, UPDATE IT
               
    {
                 
    $result query("INSERT INTO marks (studentid, subject, scores) VALUES (?, ?, ?)"$studentid$value$_POST['subject']);
                 if( 
    $result===false)
                   
    apologize("Could not update student scores");
               }
               else
               {
                 
    $result query("UPDATE marks SET scores = ? WHERE studentid = ? AND subject = ?"$value$studentid$_POST['subject']);
                 if( 
    $result===false)
                   
    apologize("Could not update student scores");
               }
             }
             
          } 
    Quote Originally Posted by jay93 View Post
    and your question about per semester, per month, week, etc... actually what i have in mind is that the teacher is going to insert marks only once for any subject...
    OK
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  14. #39
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wait, i did those changes, but nothing changed, in fact previously i was able to replace all the subjects with another one, but now even that too isnt changing.....

  15. #40
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and how about the emailing, i'm still wondering about how to email everyone, could you guide me on that?

  16. #41
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jay93 View Post
    wait, i did those changes, but nothing changed, in fact previously i was able to replace all the subjects with another one, but now even that too isnt changing.....
    Yikes, I had a typo
    PHP Code:
             //After teacher has entered marks...........
             
    if ($_SERVER["REQUEST_METHOD"] == "POST")
          {
             if (empty(
    $_POST['subject']))
             
    apologize("Please select a subject");
             
          
    // run update query setting the mark for the subject to $value 
             
    foreach ($_POST['mark'] as $studentid => $value)
             {
               
    $subjectExistsForStudent query("SELECT scores FROM marks WHERE studentid = ? AND subject = ?"$studentid$_POST['subject']);
               if (
    $subjectExistsForStudent === false// check if the subject is already in the table, if it isn't INSERT it, otherwise, UPDATE IT -- May need to change this to sizeof($subjectExistsForStudent) === 0
               
    {
                 
    $result query("INSERT INTO marks (studentid, subject, scores) VALUES (?, ?, ?)"$studentid$_POST['subject'], $value); // I had scores and subject in the wrong order
                 
    if( $result===false)
                   
    apologize("Could not update student scores");
               }
               else
               {
                 
    $result query("UPDATE marks SET scores = ? WHERE studentid = ? AND subject = ?"$value$studentid$_POST['subject']);
                 if( 
    $result===false)
                   
    apologize("Could not update student scores");
               }
             }
             
          } 
    As for sending the e-mail, you need query the student's e-mail address and use mail($studentEmailAddress, 'Subject', 'Message'); when the result of the UPDATE or INSERT is successful
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  17. #42
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and where do we specify the subject and the message of the email?? pardon me, but i've never used this function before...


    2. and another thing i wished to do was to fetch top articles from another website such as health.yahoo.net onto a webpage on mine, how does that sound??
    3. and a page where students could enter whatever they wanted to search into two search boxes, one which directly displayed results from google, and the other from wikipedia ( not that when they click search they are redirected to google or wikipedia, but rather clicking hte button displays the actual results...))

  18. #43
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i heard we could do something like $str = file_get_contents($url);... ????

  19. #44
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jay93 View Post
    and where do we specify the subject and the message of the email?? pardon me, but i've never used this function before...
    Just put whatever you want in place of Subject and Message.

    Quote Originally Posted by jay93 View Post
    2. and another thing i wished to do was to fetch top articles from another website such as health.yahoo.net onto a webpage on mine, how does that sound??
    3. and a page where students could enter whatever they wanted to search into two search boxes, one which directly displayed results from google, and the other from wikipedia ( not that when they click search they are redirected to google or wikipedia, but rather clicking hte button displays the actual results...))
    That is more complicated than you think.

    Quote Originally Posted by jay93 View Post
    i heard we could do something like $str = file_get_contents($url);... ????
    No, that isn't a good idea, you will capture everything from that URL, not just the results.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  20. #45
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ***gulp, thanks for warning me before hand about the complexity... actually someone of my level of knowledge did a website that displayed top trending youtube news videos from everyday, so i was thinking why not articles instead?

    and aboutthe email, this is what i did but nothing happened...



    Code:
    //After teacher has entered marks...........
             if ($_SERVER["REQUEST_METHOD"] == "POST")
          {
             if (empty($_POST['subject']))
             apologize("Please select a subject");
             
          // run update query setting the mark for the subject to $value 
             foreach ($_POST['mark'] as $studentid => $value)
             {
               $subjectExistsForStudent = query("SELECT scores FROM marks WHERE studentid = ? AND subject = ?", $studentid, $_POST['subject']);
               if (sizeof($subjectExistsForStudent) === 0) // check if the subject is already in the table, if it isn't INSERT it, otherwise, UPDATE IT -- May need to change this to sizeof($subjectExistsForStudent) === 0
               {
                 $result = query("INSERT INTO marks (studentid, subject, scores) VALUES (?, ?, ?)", $studentid, $_POST['subject'], $value); // I had scores and subject in the wrong order
                
                 
                 if( $result===false)
                   apologize("Could not update student scores");
                   
                 else
                 {   $studentEmailAddress = query("SELECT email FROM users WHERE id = ?", $studentid);
                     $studentEmailAddress = $studentEmailAddress['0']["email"];
                     
                     mail($studentEmailAddress, 'New Scores Uploaded!', 'Dear Student, for your information, scores for your most recent
                     examination have been uploaded. Please visit Med Buddy to view your score. Thank you.');
                 }
               }
               else
               {
                 $result = query("UPDATE marks SET scores = ? WHERE studentid = ? AND subject = ?", $value, $studentid, $_POST['subject']);
                 if( $result===false)
                   apologize("Could not update student scores");
                  else
                 {   $studentEmailAddress = query("SELECT email FROM users WHERE id = ?", $studentid);
                     $studentEmailAddress = $studentEmailAddress['0']["email"];
                     
                     mail($studentEmailAddress, 'New Scores Uploaded!', 'Dear Student, for your information, scores for your most recent
                     examination have been uploaded. Please visit Med Buddy to view your score. Thank you.');
                 }  
               }
             }

  21. #46
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    //After teacher has entered marks...........
             
    $message =<<<EMAIL_MESSAGE
    'Dear Student, for your information, scores for your most recent examination have been uploaded. Please visit Med Buddy to view your score. Thank you.
    EMAIL_MESSAGE;
             if (
    $_SERVER["REQUEST_METHOD"] == "POST")
          {
             if (empty(
    $_POST['subject']))
             
    apologize("Please select a subject");
             
          
    // run update query setting the mark for the subject to $value 
             
    foreach ($_POST['mark'] as $studentid => $value)
             {
               
    $subjectExistsForStudent query("SELECT scores FROM marks WHERE studentid = ? AND subject = ?"$studentid$_POST['subject']);
               if (
    sizeof($subjectExistsForStudent) === 0
               {
                 
    $result query("INSERT INTO marks (studentid, subject, scores) VALUES (?, ?, ?)"$studentid$_POST['subject'], $value);
                 
                 if( 
    $result===false)
                 {
                   die(
    'Failed to INSERT new record');
                   
    apologize("Could not update student scores");
                 }
                 else
                 {   
                     die(
    'Send E-mail after INSERT');
                     
    $studentEmailAddress query("SELECT email FROM users WHERE id = ?"$studentid);
                     
    $studentEmailAddress $studentEmailAddress['0']["email"];
                     
                     
    mail($studentEmailAddress'New Scores Uploaded!'$message);
                 }
               }
               else
               {
                 
    $result query("UPDATE marks SET scores = ? WHERE studentid = ? AND subject = ?"$value$studentid$_POST['subject']);
                 if( 
    $result===false)
                 {
                   die(
    'Failed to UPDATE existing record');
                   
    apologize("Could not update student scores");
                 }
                  else
                 {   
                     die(
    'Send E-mail after UPDATE');
                     
    $studentEmailAddress query("SELECT email FROM users WHERE id = ?"$studentid);
                     
    $studentEmailAddress $studentEmailAddress['0']["email"];
                     
                     
    mail($studentEmailAddress'New Scores Uploaded!'$message);
                 }  
               }
             } 
    Which die statement is being shown?
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  22. #47
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this one.... Send E-mail after INSERT ...

  23. #48
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    So it inserted the data, then got to the point of trying to send the email.

    Can you confirm it inserted the data?
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  24. #49
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i just checked, it insnt inserting data... it does so only for my id, (ie. the id of the teacher logged in gets updated on the table,but no student does......the form displays the teachers name too, just by default kind of)...

  25. #50
    SitePoint Zealot
    Join Date
    Feb 2013
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    take a look at my table....

    CAP.JPG


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
  •