|
Posted by "Gustav Wiberg" on 08/29/05 21:50
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
Navigation:
[Reply to this message]
|