뷰 파일에 배열에 문제가 있습니다. 각 타이틀에 대한 챔피언으로서의 Vacant와 각 타이틀에 대한 각 경쟁자에 대한 미정 (TBD)을 보여줄 때 가치가있을 때 나는 그 타이틀을위한 타이틀과 경쟁자 목록을 보여줍니다.올바른 값을 반향 출력하지 않습니다.
테이블에서 championID의 값이 0 인 경우 테이블에 Vacant가 표시되지 않으면 챔피언 이름을 표시하고 표시해야합니다. 각 경쟁자에 대해 0이 그 후 자신의 이름을 표시해야하지 않을 경우 데이터베이스 다음은 TBD를 표시해야합니다 여기
는 쿼리의 :./**
* Get title champions
*
* @return object/NULL
*/
function getTitlesChampions()
{
$this->db->select('titlesList.titleName');
$this->db->select('rosterList.rosterName AS champion');
$this->db->select('con1.rosterName AS contender1');
$this->db->select('con2.rosterName AS contender2');
$this->db->select('con3.rosterName AS contender3');
$this->db->from('titlesChampions');
$this->db->join('titlesList', 'titlesList.id = titlesChampions.titlesListID');
$this->db->join('rosterList', 'rosterList.id = titlesChampions.championID', 'left');
$this->db->join('rosterList AS con1', 'con1.id = titlesChampions.contender1ID', 'left');
$this->db->join('rosterList AS con2', 'con2.id = titlesChampions.contender2ID', 'left');
$this->db->join('rosterList AS con3', 'con3.id = titlesChampions.contender3ID', 'left');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return null;
}
값
id - 1 titlesListID - 1 championID - 1 contender1ID - 1 contender2ID - 1 contender3ID - 1
id - 2 titlesListID - 2 championID - 1 contender1ID - 0 contender2ID - 0 contender3ID - 0
id - 3 titlesListID - 3 championID - 1 contender1ID - 0 contender2ID - 0 contender3ID - 0
내가보기 파일에 배열의 인 print_r을 실행하고이 출력합니다 것입니다 :
Array
(
[0] => stdClass Object
(
[titleName] => Undisputed Heavyweight Title
[champion] => Kid Wonder
[contender1] => Kid Wonder
[contender2] => Kid Wonder
[contender3] => Kid Wonder
)
[1] => stdClass Object
(
[titleName] => Outlaw Title
[champion] => Kid Wonder
[contender1] =>
[contender2] =>
[contender3] =>
)
[2] => stdClass Object
(
[titleName] => Tag Team Titles
[champion] => Kid Wonder
[contender1] =>
[contender2] =>
[contender3] =>
)
)
<?php if (!is_null($titlesChampionsList)) { foreach ($titlesChampionsList AS $champion) {
echo '<tr>';
echo '<td>'.$champion->id.'</td>';
echo '<td>'.$champion->titleName.'</td>';
echo '<td>';
if ($champion->champion == 0)
{
echo 'Vacant';
}
else {
$champion->champion;
}
echo '</td>';
echo '<td>';
if ($champion->contender1 == 0)
{
echo 'TBD';
}
else {
$champion->contender1;
}
echo '</td>';
echo '<td>';
if ($champion->contender2 == 0)
{
echo 'TBD';
}
else {
$champion->contender2;
}
echo '</td>';
echo '<td>';
if ($champion->contender3 == 0)
{
echo 'TBD';
}
else {
$champion->contender3;
}
echo '</td>';
echo '<td style="text-align: center">';
$data = array('name' => 'user', 'value' => $champion->id);
echo '<a href="bios/edituser"><img src='.base_url().'assets/img/icons/packs/fugue/24x24/plus-circle.png /></a>';
echo '<img src='.base_url().'assets/img/icons/packs/fugue/24x24/cross-circle.png id="delete"/>';
echo '</td>';
echo '</tr>
'; } } ?>
모든 아이디어 titlesChampions 테이블의 안쪽이 무엇입니까? 그 배열을 가정
무엇 정확하게 인쇄할까요 ??? – Baba
게시물을 인쇄하여 업데이트해야합니다. –