473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to get percentage from mysql grading program

232 100+
i want to give grade to schools according to their student pass percentage
just lile this kindly help me to find easiest way to do this

Expand|Select|Wrap|Line Numbers
  1. $sql1 = mysql_query("select count(studentid) as totstudent from result where schoolcode ='".$_GET['schoolcode']."'" );
  2.  
  3.    if(!$sql1) { echo mysql_error();}
  4.     $sql3 = mysql_query("select count(pass_fail) as totpasstudent from result where schoolcode ='".$_GET['schoolcode']."' and pass_fail='p'" );
  5.  
  6.    if(!$sql3) { echo mysql_error();}
  7.  
  8.    $paspercentage=(totpasstudent/totstudent)*100
Aug 20 '09 #1
1 2281
ziycon
384 256MB
This is a very quick crude way to do it.
Expand|Select|Wrap|Line Numbers
  1. $sql = mysql_query("select count(studentid) as totstudent from result where schoolcode ='".$_GET['schoolcode']."'" );
  2. $row = mysql_fetch_array($sql);
  3.  
  4. $sql2 = mysql_query("select count(pass_fail) as totpasstudent from result where schoolcode ='".$_GET['schoolcode']."' and pass_fail='p'" );
  5. $row2 = mysql_fetch_array($sql2);
  6.  
  7. $paspercentag = round(($row2['totpasstudent']/$row['totstudent'])*100, 2);
Aug 25 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Saqib Ali | last post by:
I have set up MySQL on my machine and can successfully use it. However, I'm trying to set up TOra so that I can browse the databases effectively. I'm having lots of trouble trying to get TOra to...
0
by: C.E.O. Gargantua | last post by:
http://blog.seattlepi.nwsource.com/microsoft/ Featured in the blog: Grading Bill Gates Charles Cooper, CNet News.com executive editor, assesses the performance of Bill Gates as the company's...
2
by: thomasamillergoogle | last post by:
I am going to be distributing a shareware application soon and would like to know what percentage of MS OS machines have the framework installed. I have looked in multiple places (google,...
3
by: Akinyemi | last post by:
I am writing a Visual Basic program for calculating students scores, and also grading the highest 3 scores as "First" , "Second" and "Third" respectively. I have been able to get the program to...
4
by: hjc | last post by:
i am trying to created a program that will write a grading program for a class with the following policies there are 2 quizzes each graded on the basis of 10 points there is 1 midterm and 1...
17
by: Brian Blais | last post by:
Hello, I have a couple of classes where I teach introductory programming using Python. What I would love to have is for the students to go through a lot of very small programs, to learn the...
9
by: Grimmjow04 | last post by:
first of all, im a beginner with this thing.. turbo C,, my prof gave us a homework: we must do a grading system consist of: format>>> Grading System Enter your name:
3
by: smileyangeluv | last post by:
Hi, Would like to get percentage for generated column. Any idea on how to do that?? Following SQL statement SELECT s.Selection_Desc, count(u.user_id) from tbl_system_selection s, tbl_user...
1
7 of 9
by: 7 of 9 | last post by:
Hello all, Here is my question. I have a query that calculates the average weight of an item. I would like to assign that weight to a predefined grade. Let’s say I have the following grading...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.