divide-column?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there!

How do I do a sort in PHP where a column in a db must be two other columns divided...`?

I tried to use DIV-function in MySQL but it doesn't seem to work ): Of course, I can hard-code it, but i want this value because of sorting ten largest of the resultvalue. ($gradeJoke). Ten best jokes I want to get and ten worst jokes.. .

Some of my code looks like this:

   while ($toarray = mysql_fetch_array($querys)) {

       $IDJoke = $toarray["IDJoke"];
       $titleJoke = $toarray["titleJoke"];
       $fromJoke = $toarray["fromJoke"];
       $nrOfVotes = $toarray["nrOfVotes"];
       $totalValueJoke = $toarray["totalValueJoke"];
       $gradeJoke = $toarray["gradeJoke"];

     if ($totalValueJoke >0 AND $nrOfVotes > 0) {

           $gradeJoke = ($totalValueJoke / $nrOfVotes);

       }
      else {

           $gradeJoke = 0;

       }

I want this: $gradeJoke = ($totalValueJoke / $nrOfVotes);

to be integrated in MySQL, is it possible? (I guess it is, but what function do i USE?)

/G
@varupiraten.se

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux