I have a query in a table which displays all the information about individual companies and their ranking, which formed a separate (second) request is from a completely different table.
$result = mysql_query("SELECT * FROM company",$link);
If (mysql_num_rows($result) > 0)
{
$company = mysql_fetch_array($result);
do
{
$id_company = $company["id_с"];
$query2 = mysql_query("SELECT id_company, sum( price + drc) FROM user WHERE id_company = $id_company group by id_company",$link);
$result2 = mysql_fetch_array($query2);
$rating = round(($result2["1"] * 100 / 5555),1);
if($rating == ")
{
$rating = 0;
}
echo '
<a href="company?id='.$company[" id_c"].'">'.$company["name_c"].' rating $rating</a>
';
}
while($company = mysql_fetch_array($result));
}
How to sort the first query by the second. There is a view in the variable $rating