2014-05-25 39 views
0

我有问题,在我的笨视图显示显示数据笨VIEW不能行

我有在笨“查看”我的数据库显示有问题,我已经能够别使用表加载我的数据库和显示数据,但数据是通过使用进行垂直通过使用行向下延伸,而我要通过使用柱水平地显示它

[我的在浏览器画面显示]
[数据1]
[数据2 ]
[数据3]
[等等]

我的看法,我想!
[数据1] [数据2] [数据3] [等]

这是我的控制器编码:

function coba(){ 
    // nyobain nge load td secara multiple 
$data['query'] = $this->Latihan_model->coba()->result(); 
$this->load->view('rubbish/coba',$data); 
} 

这是我的模型代码:

function coba(){ 
$sql = (" 
    SELECT soal.ID_soal as soal 
    from soal 
    where soal.ID_bagian = 1; 
    "); return $this->db->query($sql); 
} 

这是我的查看代码:

<table border=1> 
<?php foreach($query as $post): ?> 
<tr> 
    <td><? echo $post->soal; ?></td> 
</tr> 
<?php endforeach; ?> 

我希望你明白我问

+0

移动的'tr'外的foreach? – lighter

+0

非常感谢你的帮助我 –

+0

我输入了我的答案。希望这会对你有所帮助。 – lighter

回答

1

你可以试试这个

<table border=1> 
<tr> 
<?php foreach($query as $post): ?> 
    <td><? echo $post->soal; ?></td> 
<?php endforeach; ?> 
</tr> 
0

试试这个:

<?php foreach($query as $key => $value): ?> 
<tr> 
    <?php foreach($key as $val): ?> 
     <td><?php echo $val; ?></td> 
    <?php endforeach; ?> 
</tr> 
<?php endforeach; ?>