我想知道我是否会按照评分在每个网站名单上显示一个数据?因为我现在拥有的是,在每个站点中按评级显示所有数据顺序。更清楚我真正想要的是:
如果网站等于该人的网站列,则
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*
-----------------------------------------------------
到目前为止我的代码:
$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>";
}
}
我的职能
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;
}
先谢谢你们!