Note that there are some explanatory texts on larger screens.

plurals
  1. POcalculating percentile for huge database
    primarykey
    data
    text
    <p>i have huge database containing student information about test code and the marks achieved for those test code. I need to recompute percentile marks for students corresponding to each test codes. I have a code for a series of test code but it doesn't work properly.</p> <pre><code>function recompute_percentiles() { if($_REQUEST[testcode]=="CAT B1" or $_REQUEST[testcode]=="CAT B2" or $_REQUEST[testcode]=="CAT B3" or $_REQUEST[testcode]=="CAT B4") { echo "&lt;br /&gt;Got testcode: ".$_REQUEST[testcode]; $getsortedq=mysql_query("SELECT username, section1right as m from kmarks where testcode='.$_REQUEST[testcode].' order by section1right DESC"); if(!$getsortedq) echo "Could not get the sorted query"; else echo "got the sorted query quick"; $totalcount=mysql_num_rows($getsortedq); while($r=mysql_fetch_array($getsortedq)) { $u=$r[username]; $m=$r[m]; $array[$u]=$m; } $array2=$array; //print_r($array2); $updated=0; foreach($array as $key=&gt;$value) { $countsame=0; foreach($array2 as $k=&gt;$v) { if($v&gt;=$value) $countsame++; else break; } $countless = $totalcount - $countsame; reset($array2); $percentile=round($countless/$totalcount*100,2); $updatep1q=mysql_query("UPDATE kmarks set percentile1=$percentile where username='.$key.' and testcode='.$_REQUEST[testcode].'"); if(!$updatep1q) echo "&lt;br /&gt;Could not update p1 for username: ".$key; else $updated++; } echo "&lt;br /&gt;Updated ".$updated." records in kmarks db, out of ".$totalcount." records for testcode ".$_REQUEST[testcode]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload