이 코드가 있습니다. 그리고 배열에서 데이터를 인쇄해야합니다. 문제는 내가 2 열, 하나의 이름과 두 번째를 가진 테이블을 설계했습니다. 그리고 난 두 열에있는 값을 인쇄하는 방법을 모르겠습니다.테이블의 배열을 두 열로 인쇄하십시오.
class Tabel{
private $tabel = array();
public function getElemente(){
$conn = mysql_connect('localhost','root','');/
$db_selected = mysql_select_db('world',$conn);
$result = mysql_query("SELECT c.Continent, COUNT(c.Name) FROM country c
GROUP BY c.Continent
Order By COUNT(c.Name) desc");
while($row = mysql_fetch_array($result)){
//echo $row['Continent'] . " " . $row['COUNT(c.Name)']."<br>";
$this->tabel[]=$row['Continent']. " " . $row['COUNT(c.Name)'];
}
}
public function afisare(){
print_r($this->tabel);
echo"<table border=1 cellpading=0 cellspacing=0 >";
echo"<th>Continent</th>";
echo"<th>Tari</th>";
foreach($this->tabel as $value){
echo"<tr>";
echo"<td>".$value."</td>";
echo"</tr>";
}
}
나는 매트릭스와 연관 배열에 대해 생각했다. 나는 약간의 아이디어를 시도했다. 그러나 어떤 운도. 구문이 나를 죽이고있다.
그다지 좋지 않습니다. 정의되지 않은 인덱스에 관한 이상한 오류가 발생합니다. 나는 이것을했다 : private $ tabel = array (array()); 그리고 ... 나는 이것을 얻는다 : 알림 : 정의되지 않은 인덱스 : 대륙의 ... and otice : 정의되지 않은 인덱스 : count in ... at afisare() –
이 오류를 게시 할 수 있습니까? – Chris
Here : http://postimg.org/image/w1sn56wd1/ –