Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 11th, 2005, 04:23 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default retrieve and display selected results

My code will print the table of student result. If previous screen selected 2 students, it will print 2 students' records. when display the tables, I can get everything correct except student's marks and grades. All tables print same results. Please advice. Thank you.


<?php

$getst = $_POST["select"];
$getcid = $_POST["cid"];
$getcyr = $_POST["cyr"];
$geteid = $_POST["eid"];
$getnum = $_POST['num'];

foreach ($getst as $getstid)
{

    //get school name
    $rs = mysql_query("select SC_NAME from EDUCATION.SCHOOL");
    while ($newArray = mysql_fetch_array($rs))
    {
        $scname=$newArray['SC_NAME'];
    }

    // get exam name
    $rs = mysql_query("select E_DESC from EDUCATION.EXAM where E_ID = '$geteid'");
    while ($newArray = mysql_fetch_array($rs))
    {
        $edesc=$newArray['E_DESC'];
    }

    //get student, class, and teacher record
    $rs = mysql_query("select STUDENT.ST_NAME, STUDENT.ST_BEH, CLASS.C_NAME, TEACHER.T_NAME from EDUCATION.STUDENT, EDUCATION.CLASS, EDUCATION.TEACHER where STUDENT.ST_ID = '$getstid' and STUDENT.C_ID = '$getcid' and CLASS.C_YR = '$getcyr' and CLASS.C_ID = STUDENT.C_ID and CLASS.T_ID = TEACHER.T_ID");
    while ($newArray = mysql_fetch_array($rs))
    {
        $stname=$newArray['ST_NAME'];
        $stbeh=$newArray['ST_BEH'];
        $cname=$newArray['C_NAME'];
        $tname=$newArray['T_NAME'];

    }

    $number=0;

    // get subjects, marks, grade, total, average, post_class and post_std
    $rs = mysql_query("select distinct SUBJECT.SUB_DESC, SUB_ACH.MARKS, SUB_ACH.GRADE, OV_ACH.* from EDUCATION.SUB_ACH, EDUCATION.OV_ACH, EDUCATION.SUBJECT where SUB_ACH.ST_ID = '$getstid' and SUB_ACH.E_ID = '$geteid' and SUB_ACH.C_YR = '$getcyr' and OV_ACH.ST_ID = '$getstid' and OV_ACH.E_ID = '$geteid' and OV_ACH.C_YR = '$getcyr' and SUBJECT.SUB_CODE = SUB_ACH.SUB_CODE");
    while ($newArray = mysql_fetch_array($rs))
    {
        $subdesc[]=$newArray['SUB_DESC'];
        $total=$newArray['TOTAL'];
        $average=$newArray['AVERAGE'];
        $postclass=$newArray['POST_CLASS'];
        $poststd=$newArray['POST_STD'];
        $marks[] = $newArray['MARKS'];
        $grade[] = $newArray['GRADE'];
        $number++;

    }

    $rs = mysql_query("select GRADE from education.scale where YEAR = '$getcyr' and MIN <= '$average' order by MIN desc limit 1");
    while ($newArray = mysql_fetch_array($rs))
    {
        $avgGrade = $newArray['GRADE'];
    }

    ?>

    <table align="center" width="75%" border="1" cellspacing="0.3">
      <tr>
        <th colspan="6">
          <?php
    print "<BR>".$scname."<BR>";
    print $edesc." RESULT SLIP<BR><BR>";
    ?>
        </th>
      </tr>
      <tr>
        <th>STUDENT NAME:</th>
        <th colspan="2"><?php print $stname; ?></th>
        <th>TEACHER:</th>
        <th colspan="2"><?php print $tname; ?></th>
      </tr>
      <tr>
        <th>STUDENT ID:</th>
        <th colspan="2"><?php print $getstid; ?></th>
        <th>CLASS ID:</th>
        <th colspan="2"><?php print $cname; ?></th>
      </tr>
      <tr>
        <td colspan="6">&nbsp;</td>
      </tr>
      <tr>
        <th width="17.5%">SUBJECT</th>
        <th width="10%">MARKS</th>
        <th width="10%">GRADE</th>
        <th width="17.5%">SUBJECT</th>
        <th width="10%">MARKS</th>
        <th width="10%">GRADE</th>
      </tr>

    <?php
    for ($loop=0; $loop<$number; $loop++)
    {
        print "<tr><th>".$subdesc["$loop"]."</th>";
        print "<td align='center'>".$marks["$loop"]."</td>";
        print "<td align='center'>".$grade["$loop"]."</td>";
        $loop++;
        print "<th>".$subdesc["$loop"]."</th>";
        print "<td align='center'>".$marks["$loop"]."</td>";
        print "<td align='center'>".$grade["$loop"]."</td></tr>";

    }

    ?>

      <tr>
        <td colspan="6">&nbsp;</td>
      </tr>
      <tr>
        <th>TOTAL</th>
        <td colspan="2" align="center"><?php print $total; ?></td>
        <th>GRADE</th>
        <td colspan="2" align="center"><?php print $avgGrade; ?></td>
      </tr>
      <tr>
        <th>AVERAGE</th>
        <td colspan="2" align="center"><?php print $average; ?></td>
        <th>POSITION</th>
        <td colspan="2" align="center"><?php print $postclass; ?></td>
      </tr>
      <tr>
        <td colspan="6">&nbsp;</td>
      </tr>
      <tr>
        <th>REMARKS</th>
        <td colspan="5"><?php print "<BR>".$stbeh."<BR><BR>"; ?></td>
      </tr>
      <tr>
        <th><BR>TEACHER<BR>SIGNATURE<BR><BR></th>
        <td>&nbsp;</td>
        <th>HEADMASTER<BR>SIGNATURE
        </th>
        <td>&nbsp;</td>
        <th>PARENTS<BR>SIGNATURE</th>
        <td>&nbsp;</td>
      </tr>
    </table>
    <br><br>
<?php
}
?>


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve and Display Image asters .NET Framework 1.x 0 September 18th, 2008 03:56 AM
retrieve 2 different results on column abc052107 Visual Studio 2005 2 July 31st, 2007 03:31 PM
display results carswelljr ASP.NET 2.0 Basics 1 April 19th, 2007 09:46 AM
How do I display search results... aspiretech9 PHP How-To 1 April 26th, 2005 10:12 AM
Qry to retrieve from 2 tables and display tsimsha Classic ASP Databases 3 October 29th, 2004 02:03 AM



All times are GMT -4. The time now is 03:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.