Jump to content

Sorting Problem (PHP+SQL)


MesCasinos

Recommended Posts

HI,

 

- First I've attached the original PHP file, which you will need. This file is included in a page.

- Second, sorry for my english, this is not my primary language  :P

 

Ok, the page I've attached currently dont sort the casinos: http://www.mescasinos.net/meilleurs-casinos.php

 

In my webpage, you can see the overal rating with the stars which is the average of fields ['note_'] for each casinos, this rating is made by mathematic (line 45):

 

$number = ($row['note_rep'] + $row['note_graph'] + $row['note_bmatch'] + $row['note_bmax'] + $row['note_bgratuit'] + $row['note_jackpot'] + $row['note_varjeux'] + $row['note_languages'] + $row['note_bloyauter'] + $row['note_jeuxmulti'] + $row['note_metpaiement'] + $row['note_metretrait'] + $row['note_support'])/13;

 

 

I want to get my casinos sorted DESC by this overal rating

 

Normaly, to get something sorted i use:

$result = mysql_query("SELECT * FROM casinos ORDER BY something DESC");

 

But here the average is $number and i can't use it in the "mysql_query" and in the "while"

 

This is how i think the things must be but im not sure if thats the good way to make it:

 

should make the average of all the fields ['note_'] for each casinos in my table and sort them after

 

Example:

 

Table "casinos"

 

 

   

nom

   

note_rep

   

note_graph

   

note_support

   

bonus

 

 

   

tropez

   

9

   

6

   

6

   

100%

 

 

   

rushmore

   

8

   

7

   

9

   

150%

 

 

   

bellini

   

9

   

9

   

9

   

100%

 

 

The average of tropez is 7.6

The average of rushmore is 8

The average of bellini is 9

 

so in my webpage the casinos will be sorted:

 

bellini

rushmore

tropez

 

I hope you guys understand what i want say  :P

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/193420-sorting-problem-phpsql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.