本文介绍了如何使用php挖掘mysql结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为vw_results的表,其中包含特定学生的结果配置文件:

I have a table called vw_results which holds the result profile for a particular student:

idNum      |courseUnit | marks | Gpp | grade| id | semseterID | sessionName

06/021     |   2       | 47    | 8   |  B+  | 1  |   1        |  2010/11
06/021     |   3       | 56    | 7   |  C   | 1  |   1        |  2010/11
06/021     |   4       | 34    | 5   |  C   | 1  |   1        |  2010/11
06/021     |   5       | 34    | 0   |  F   | 1  |   1        |  2010/11
06/021     |   2       | 89    | 10  |  A   | 1  |   2        |  2010/11
06/021     |   3       | 45    | 4   |  D   | 1  |   2        |  2010/11
06/021     |   4       | 56    | 10  |  C   | 1  |   2        |  2010/11
06/021     |   2       | 67    | 12  |  B+  | 2  |   1        |  2011/12
06/021     |   1       | 70    | 15  |  A   | 2  |   1        |  2011/12
06/021     |   2       | 80    | 10  |  A   | 2  |   2        |  2011/12
06/021     |   3       | 90    | 5   |  A   | 2  |   2        |  2011/12



我有一个使用GET方法的表单有两个名为sessionID和semesterID的选择框,部分PHP代码是


I have a form that uses GET method having two select boxes named sessionID and semesterID, part of the php code is

 <?php
    ...

#To calculate the GPA

if(isset('chkresult')){

$query="SELECT SUM( vwr.courseUnit ) cummUnit, SUM( vwr.GPP ) cummGPP, (
SUM( vwr.GPP ) / SUM( vwr.courseUnit ))cummGPA
FROM vw_result vwr
WHERE vwr.Grade NOT IN ('F') AND vwr.sessionID=".$_GET['sessionID']." AND vwr.semesterID=".$_GET['semesterID'].";"
$result=mysql_query($query);
$row_query=mysql_fetch_assoc($result);
}
...
?>;



假设我想累计计算CGPA,这样当 $ _ GET [''sessionID''] = 1 $ _ GET [''semesterID''] = 2 它包含 sessionID = 1 semesterID = 2 ,这样:

<?php echo $ row_query [''cummGPA' ]; ????

结果将是:


supposing I want to calculate the CGPA cummmulatively such that when $_GET[''sessionID'']=1 and $_GET[''semesterID'']=2 it includes the result of GPA computation for sessionID=1 and semesterID=2, such that:
<?php echo $row_query[''cummGPA'']; ???>
the result will be:

|cummGPA|
|2.444  |



如果 $ _ GET [''sessionID''] = 2 $ _ GET [''semesterID''] = 1

然后它包含 sessionID = 1 semesterID = 1 ; sessionID = 1 semesterID = 2


also if $_GET[''sessionID'']=2 and $_GET[''semesterID'']=1
then it includes the result of GPA computation for sessionID=1 and semesterID=1; sessionID=1 and semesterID=2,

|cummGPA|
|3.381  |



如果 $ _ GET [''sessionID''] = 2 $ _ GET [''semesterID''] = 2

然后


if $_GET[''sessionID'']=2 and $_GET[''semesterID'']=2
then

|cummGPA|
|3.301  |



有关MySQl和PHP语句的任何建议,请使用上面的vw_result表或者新的想法来获取此信息。

谢谢!


any suggestions on MySQl and PHP statements to go about this using the vw_result table above or a new idea is highly appreciated.
THANKS!

推荐答案




这篇关于如何使用php挖掘mysql结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 03:48