Hello In the sql i have bellow it currently prints out the stuff from the database like this home 1 home 2 home 3 but how can i insteed make it print it out in 3 lines each insted like this insteed ? home 1 home 2 home 3 home 4 home 5 home 6 $sql = '$sql = 'SELECT * FROM `homes` ORDER BY `homes`.`homes` ASC'; $r = $db->_sql($sql); while ($row = $db->fetch_row($r)) { $tpl->set('q_id', $row['id']); $tpl->set('quote', $row['homes']); print($tpl->fetch($tpl->tdir.'quote_block2.tpl')); } PHP:
Try something like this: $sql = '$sql = 'SELECT * FROM `homes` ORDER BY `homes`.`homes` ASC'; $r = $db->_sql($sql); $columns = 3; $column = 0; echo "<table>\n"; while ($row = $db->fetch_row($r)) { if($column == 0){echo "\n<tr>";} echo "\n\t<td>"; $tpl->set('q_id', $row['id']); $tpl->set('quote', $row['homes']); print($tpl->fetch($tpl->tdir.'quote_block2.tpl')); echo "</td>"; if($column == $columns){ echo "\n</tr>"; $column = 0; }else{ $column++; } } echo "\n</table>"; Code (markup):