divide-column?
| From: | Gustav Wiberg | Date: | Mon, 29 Aug 2005 18:50:05 +0000 |
| Subject: | divide-column? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-221539@lists.php.net to get a copy of this message | ||
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