0

I'm wondering if how I gonna display one data at every sitename order by rating? Because what I have now is, display all data order by rating in each site. to be more clear what I really want is this:

if the site is equal of the site column of the person then

site: nameone
 - name
 - rating: 10
 - site name: nameone

site: nametwo
 - name
 - rating: 10
 - site name: nametwo

site: nameone
 - name
 - rating: 9
 - site name: nameone

*and so on*

-----------------------------------------------------

my code so far:

$rowssite = $db->getSiteOrder();
foreach($rowssite as $siterow)
{
    $rows = $db->people($siterow['acronym']);
    foreach($rows as $row)
    {
        echo $row['name'] . "<br>";
        echo $row['site'] . "<br>";
        echo $row['rate'] . "<br>";
    }

}

my functions

function getSiteOrder()
    {
        $query = mysqli_query($this->connect,"SELECT * FROM `dynamic_sites` ORDER BY `site_order` ASC") or die(mysql_error());
        while($row = mysqli_fetch_assoc($query))
        {
            $rows[] = $row;
        }
        return $rows;
    }

    function people($siteacronym)
    {
        $query = mysqli_query($this->connect,"SELECT `person`.`mname` as `fullname`, `person`.`msite` as `site`, `person`.`mtoursrate` as `rating` FROM `person` LEFT JOIN `dynamic_sites` ON `person`.`msite`=`dynamic_sites`.`acronym` WHERE `person`.`msite`='".$siteacronym."' ORDER BY `person`.`mtoursrate` DESC") or die(mysql_error());
        while($row = mysqli_fetch_assoc($query))
        {
            $rows[] = $row;
        }
        return $rows;
    }

thanks in advance guys!

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • If you are ordering it by site name in the first query, you can not have the result show up by rating. It is impossible. Just use JOINS, and you won't have to use two `select` statements. You can do it all with one – samayo Nov 02 '15 at 22:42
  • what *one data you want to display*, and where you want to display? and let's say you display 1st row, than what to do with the next ones? how do you want to display them? please be more specific. – Mubin Nov 02 '15 at 22:45
  • @Mubin I want to display them one by one for each site. let say, in the sitename1 I will display the biggest rating, then the sitename2 i will display the biggest rating on them too the rating goes descending. – Sheerwood John Caday Nov 02 '15 at 22:47
  • Its marked as duplicate, i dont think the link helps me. – Sheerwood John Caday Nov 02 '15 at 22:52

0 Answers0