2014-09-15 2 views
0

나는 내가 HTML 테이블에 표시해야하는 다음과 같은 쿼리가 : 내가 필요로 인쇄 두 개의 열 배열

$query= "SELECT SUM(amount_pln) AS suma,country FROM fin_revenues GROUP BY country ORDER BY suma DESC"; 
$result = mysqli_query($mysqli,$query); 
에 phpMyAdmin에서 쿼리를 실행, 그것은 완벽하게 작동을하지만, 그럴 수 없어 html 테이블에서 동일한 결과를 얻는 방법을 찾아보십시오. phpMyAdmin에 표시되는 방법

은 :

http://oi59.tinypic.com/2ajdjtg.jpg

어떤 도움이 많이 이해할 수있을 것이다.

답변

1
$query= "SELECT SUM(amount_pln) AS suma,country FROM fin_revenues GROUP BY country ORDER BY suma DESC"; 
    $result = mysqli_query($mysqli,$query); 

    echo "<table><tr><td>SUMA</td><td>country</td></tr>"; 

    while($row = mysqli_fetch_assoc($result)){ 
    echo "<tr><td>".$row['suma']."</td><td>".$row['country']."</td></tr>"; 
    } 
echo "</table>"; 
mysqli_free_result($result); 
+0

감사합니다. 지금까지 SUMA와 country라는 제목 만 얻었습니다. – user2952715

+0

@ user2952715, 제 답변을 업데이트했습니다. 오류가 있습니까? –

+0

이제 원활하게 작동합니다! 많은 감사합니다. ;) – user2952715

1
$query= "SELECT SUM(amount_pln) AS suma,country FROM fin_revenues GROUP BY country ORDER BY suma DESC"; 
$result = mysqli_query($mysqli,$query); 
echo '<table> 
     <tr> 
      <td>Suma</td> 
      <td>Country></td> 
     </tr>'; 
while($row=mysqli_fetch_array($mysqli,$result)) // while there are records 
{ 
    echo "<tr><td>".$row['suma']."</td><td>".$row['country']."</td></tr>"; // echo the table with query results 
} 
echo '</table'; 
+0

내가 다음 줄에 오류 때문에 작은 따옴표로 보인다 " $ 행 [ '스마'] $ 행 [ '국가']"에코; – user2952715