Welcome Guest, Not a member yet? Register   Sign In
how to display query in two column?
#1

[eluser]coderedmax[/eluser]
I know this might be simple but anyone knows how to display the query result in two column in codeigniter? thanks in advance

Note: you may check my image I upload to made myself more clear.
#2

[eluser]CroNiX[/eluser]
To do that I would count the results and divide by 2 (rounding up).
Then loop through the results and create 2 ordered lists and populate them, and also have them float to the left of each other.
#3

[eluser]CroNiX[/eluser]
You can adapt something like this:
Code:
$words = array('one', 'two', 'three', 'four', 'five', 'six', 'seven');
//get our upper limit using ceil for rounding so if odd number left list will have the extra
$break_point = ceil(count($words) / 2);
        
$new_ul = '<ul style="width:150px;float:left">';
        
$html = $new_ul;
foreach($words as $counter => $word)
{
    //if we reached our limit, close first ul and start new one
    if($counter == $break_point)
    {
        $html .= '</ul>' . $new_ul;
    }
    //increment the counter for display since it starts at 0
    $cur_number = $counter + 1;
    $html .= '<li>' . $cur_number . ' - ' . $word . '</li>';
}
$html .= '</ul>';
    
echo $html;
#4

[eluser]coderedmax[/eluser]
thanks i'll try this right away =)




Theme © iAndrew 2016 - Forum software by © MyBB