나는 이런 식으로 인쇄되어야 배열하고 싶었 :은 어레이는 최대 스택 최대
[0] => 9
[id] => 9
[1] => Barcelona
[name] => Barcelona
[2] => voetbal
[type] => voetbal
[3] => 0
[organisation_id] => 26
[teams] => Array
(
[0] => Array
(
[0] => 1
[id] => 1
[1] => 2
[tag] => 2
[2] => Barcelona 2
[naam] => Barcelona 2
[3] => 9
[club_id] => 9
[0] => 2
[id] => 2
[1] => 3
[tag] => 3
[2] => Barcelona 3
[naam] => Barcelona 3
[3] => 9
[club_id] => 9
[0] => 9
)
[id] => 10
[1] => Real Madrid
[name] => Real Madrid
[2] => voetbal
[type] => voetbal
[3] => 0
[organisation_id] => 27
[teams] => Array
(
[0] => Array
(
[0] => 1
[id] => 1
[1] => 2
[tag] => 2
[2] => Real Madrid 2
[naam] => Real Madrid 2
[3] => 9
[club_id] => 10
[0] => 2
[id] => 2
[1] => 3
[tag] => 3
[2] => Real Madrid 3
[naam] => Real Madrid 3
[3] => 10
[club_id] => 10
)
을하지만 난이 받고 있어요 :
[0] => 9
[id] => 9
[1] => Barcelona
[name] => Barcelona
[2] => voetbal
[type] => voetbal
[3] => 0
[organisation_id] => 26
[teams] => Array
(
[0] => Array
(
[0] => 1
[id] => 1
[1] => 2
[tag] => 2
[2] => Barcelona 2
[naam] => Barcelona 2
[3] => 9
[club_id] => 9
[0] => 2
[id] => 2
[1] => 3
[tag] => 3
[2] => Barcelona 3
[naam] => Barcelona 3
[3] => 9
[club_id] => 9
[0] => 9
)
[id] => 10
[1] => Real Madrid
[name] => Real Madrid
[2] => voetbal
[type] => voetbal
[3] => 0
[organisation_id] => 27
[teams] => Array
(
[0] => Array
(
[0] => 1
[id] => 1
[1] => 2
[tag] => 2
[2] => Barcelona 2
[naam] => Barcelona 2
[3] => 9
[club_id] => 9
[0] => 2
[id] => 2
[1] => 3
[tag] => 3
[2] => Barcelona 3
[naam] => Barcelona 3
[3] => 9
[club_id] => 9
[0] => 9
[0] => 1
[id] => 1
[1] => 2
[tag] => 2
[2] => Real Madrid 2
[naam] => Real Madrid 2
[3] => 10
[club_id] => 10
[0] => 2
[id] => 2
[1] => 3
[tag] => 3
[2] => Real Madrid 3
[naam] => Real Madrid 3
[3] => 10
[club_id] => 10
)
누군가가 힌트 그쪽을 제공 할 때, 좀 더 배우고
$resultaat_clubs = mysql_query("SELECT * FROM sportssite_clubs");
$clubs = array();
while($club = mysql_fetch_array($resultaat_clubs)) {
$clubs[] = $club;
}
foreach($clubs as $index => $club) {
$id = $club['id'];
$result = mysql_query("SELECT * FROM eyeboxes WHERE location_id = $id");
if (mysql_num_rows($result) > 0) {
unset($clubs[$index]);
}
}
$teams = array();
foreach($clubs as $index => $club) {
$id = $club['id'];
$result = mysql_query("SELECT * FROM sportssite_teams WHERE club_id = $id");
while($team = mysql_fetch_array($result)) {
// vul de teams array
$teams[] = $team;
}
$clubs[$index]["teams"] = $teams;
}
print_r($clubs);
내가 대답하지만 힌트 또는 뭔가를하지 않는 :
여기 내 전체 코드입니다 대답. 하지만 오류를 찾을 수 없습니다, 나는 초 foreach 루프에 문제가 있다고 생각합니다.
미리 감사드립니다.
'Real Madrid' 데이터 만 원하신다면 검색어의'WHERE' 절에 추가하지 않으시겠습니까? –
@ICanHasCheezburger 배열에있는 모든 것을 인쇄하고 싶습니다. – STP38