• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 column layout for db results ?

#1
[eluser]cartalot[/eluser]
greetings,

have a maybe simple question -- would like to display results from database search as two columns in a table
each table row would have two cells
and each cell would have all the fields from the db search results - so like

Code:
table row
table cell 1
results->name1
results->detail1
results->img1

table cell 2
results->name2
results->detail2
results->img2

next table row would have results from db rows 3 and 4
etc etc

???
thanks

#2
[eluser]isawhat[/eluser]
This will give you an idea of how to do it

Code:
<table><tr>

&lt;?php
$count=0;
foreach ($yourquery->result() as $item) {
    echo '<td>'.$item->name.$item->details.$item->img.'</td>';

    $count++;
    if ($count == 2) {
        echo '</tr><tr>';
        $count=0;
    }
}
?&gt;

</tr></table>


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.