Getting the right values from sql
Moderator: General Moderators
Getting the right values from sql
Hi all
I'm working on a rating system
I got 1 problem, i dont know how to do this
i got lets say 400 records with a field "views"
i need the highest "views" from all records and the lowest "views" count
how can i do this?
I'm working on a rating system
I got 1 problem, i dont know how to do this
i got lets say 400 records with a field "views"
i need the highest "views" from all records and the lowest "views" count
how can i do this?
like this
then u can fetch the dataout and do whatever you want to do with it.
Code: Select all
<?php
$high = mysql_query("select `views` from table order by `views` DESC limit 1");
$low = mysql_query("select `views` from table order by `views` ASC limit 1");
?>Code: Select all
"select max(views), min(views) from table"re
Thanks that what i was looking for
But can i call both of them seperate with this one?
maybe i beter explain what i try to do
i want to give my games a rating based on the highest en lowest views count
highest is 345 hits
lowest is 0 hits
now i want to output a rating from these 2 counts example lets say i made this in a function and i call it from my view.php?id=53
then it looks up the hit count and compares it with the info in the function
pfff my english is bad, i hope u understand it LOL
But can i call both of them seperate with this one?
Code: Select all
<?php
"select max(views), min(views) from table"
?>maybe i beter explain what i try to do
i want to give my games a rating based on the highest en lowest views count
highest is 345 hits
lowest is 0 hits
now i want to output a rating from these 2 counts example lets say i made this in a function and i call it from my view.php?id=53
then it looks up the hit count and compares it with the info in the function
pfff my english is bad, i hope u understand it LOL
Last edited by GGK on Wed Sep 17, 2003 6:40 pm, edited 1 time in total.
I actually dont know... Nowadays we (at least I) knows these things after browsing the mysql manual more than a couple of times.
http://www.mysql.com/doc/en/Functions.html is something worth bookmarking tho.
You mean like this?
http://www.mysql.com/doc/en/Functions.html is something worth bookmarking tho.
You mean like this?
Code: Select all
$result = mysql_fetch_array(mysql_query("select max(views), min(views) from table"));
$max = $result[0];
$min = $result[1];