你好每个人我都有一个表结构像这样:
xl_Server id_server,主机名。(表父)
xl_port id_port,id_server。(餐桌孩子)
xl_connection id_Server,主机名_dst。(餐桌孩子)
和
我的控制器:
$bc['dt_connectto'] = $this->server_model->getDataConnectto($param);
我的模型:
public function getDataConnectto($param)
{
$this->db->select('*');
$this->db->from('xl_connection');
$this->db->join('xl_rack', 'xl_rack.id_rack = xl_connection.id_rack');
$this->db->join('xl_server', 'xl_connection.id_server = xl_server.id_server');
$this->db->join('xl_type_connection', 'xl_connection.id_type_connection = xl_type_connection.id_type_connection');
$this->db->where('xl_server.id_server',$param);
$query_c = $this->db->get();
if ( $query_c->num_rows() > 0 )
{
$rows = $query_c->result_array();
}
foreach ($rows as $rs) {
$key = $rs['id_server'];
}
$this->db->select('*');
$this->db->from('xl_port');
$this->db->join('xl_server', 'xl_port.id_server = xl_server.id_server');
$this->db->where('xl_server.id_server',$key);
$query_p = $this->db->get();
if ($query_p->num_rows() > 0)
{
$rows['id_server'] = $query_p->result_array();
}
return $rows;
}
我的观点
if($dt_connectto > 0)
{
foreach($dt_connectto as $db)
{
?>
<tr id="<?php echo $db['id_server']; ?>" class="edit_tr">
<!--td><?php //echo $no; ?></td-->
<td><?php echo $db['id_lantai']; ?></td>
<td><?php echo $db['equipment_type']; ?></td>
<td><?php echo $db['hostname']; ?></td>
<td><?php echo $db['port']; ?></td>
<td><?php echo $db['nama_rack']; ?></td>
<td><?php echo $db['hostname_dst']; ?></td>
<td><?php echo $db['board_slot_port']; ?></td>
<td><?php echo $db['card_equipment']; ?></td>
<td><?php echo $db['connect_via']; ?></td>
<td><?php echo $db['keterangan']; ?></td>
</tr>
<?php
// $no++;
}
}
else
{
?>
<tr style="text-align:center;">
<td colspan="5">EMPTY DATA</td>
</tr>
<?php
}
?>
输出数据如下:
Array
(
[0] => Array
(
[id_connection] => 22
[id_rack] => 12
[id_server] => 3
[id_type_connection] => 1
[board_slot_port] => FROM 01
[card_equipment] =>
[equipment_type] =>
[hostname_dst] => BDG 01
[ipaddress_dst] => -
[keterangan] =>
[id_lantai] => 2
[nama_rack] => A.15.5
[row] => A
[column] => 15
[no] => 5
[u_shaft] => 2-5
[id_userxl] => 8
[id_product] => 302
[hostname] => BDGDRCBSS04
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
[connect_via] => FO
)
[1] => Array
(
[id_connection] => 23
[id_rack] => 12
[id_server] => 3
[id_type_connection] => 1
[board_slot_port] => 02
[card_equipment] =>
[equipment_type] =>
[hostname_dst] => BDG 02
[ipaddress_dst] => -
[keterangan] =>
[id_lantai] => 2
[nama_rack] => A.15.5
[row] => A
[column] => 15
[no] => 5
[u_shaft] => 2-5
[id_userxl] => 8
[id_product] => 302
[hostname] => BDGDRCBSS04
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
[connect_via] => FO
)
[id_server] => Array
(
[0] => Array
(
[id_port] => 9
[id_server] => 3
[port] => 01
[card_equipment] => 01
[id_userxl] => 8
[id_rack] => 12
[id_product] => 302
[hostname] => BDGDRCBSS04
[equipment_type] =>
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
)
[1] => Array
(
[id_port] => 10
[id_server] => 3
[port] => 02
[card_equipment] => 02
[id_userxl] => 8
[id_rack] => 12
[id_product] => 302
[hostname] => BDGDRCBSS04
[equipment_type] =>
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
)
)
)
我的问题 如何输出数组这样的家伙?帮我...
Array
(
[0] => Array
(
[id_connection] => 22
[id_rack] => 12
[id_server] => 3
[id_type_connection] => 1
[board_slot_port] => FROM 01
[card_equipment] =>
[equipment_type] =>
[hostname_dst] => BDG 01
[ipaddress_dst] => -
[keterangan] =>
[id_lantai] => 2
[nama_rack] => A.15.5
[row] => A
[column] => 15
[no] => 5
[u_shaft] => 2-5
[id_userxl] => 8
[id_product] => 302
[hostname] => BDGDRCBSS04
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
[connect_via] => FO
[id_server] => Array
[0] => Array
(
[id_port] => 9
[id_server] => 3
[port] => 01
[card_equipment] => 01
[id_userxl] => 8
[id_rack] => 12
[id_product] => 302
[hostname] => BDGDRCBSS04
[equipment_type] =>
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
)
)
[1] => Array
(
[id_connection] => 23
[id_rack] => 12
[id_server] => 3
[id_type_connection] => 1
[board_slot_port] => 02
[card_equipment] =>
[equipment_type] =>
[hostname_dst] => BDG 02
[ipaddress_dst] => -
[keterangan] =>
[id_lantai] => 2
[nama_rack] => A.15.5
[row] => A
[column] => 15
[no] => 5
[u_shaft] => 2-5
[id_userxl] => 8
[id_product] => 302
[hostname] => BDGDRCBSS04
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
[connect_via] => FO
[id_server] => Array
[1] => Array
(
[id_port] => 10
[id_server] => 3
[port] => 02
[card_equipment] => 02
[id_userxl] => 8
[id_rack] => 12
[id_product] => 302
[hostname] => BDGDRCBSS04
[equipment_type] =>
[project_name] => Mediaserver Cloud
[ipaddress] => 10.24.125.17
)
)
)
)