Hi I want to show the table data in 2 columns lik this: category1 category2 category3 category4 category5 category6 ... but I don't know how to code within the while loop can you help? any idea? thanks
thanks for your reply. but I didn't understand also you know that category1 , 2 etc represents the categories names
for($i=0,$n=count(categories)-1;$i<=$n;$i++) { $div = $i%2 ? "div style to left or table column to left" : "div style to right or table column to right"; echo $div; echo $variable; echo "</div>"; }
Another way ... just update $colums with how many colums you want: $colums = 2; $count = 0; echo '<table><tr>'; while($row = mysql_fetch_array($result)) { echo '<td>' . $row['category'] . '</td>' ; $count += 1; if ($count == $colums){ echo '</tr><tr>'; $count = 0; } } while ($count < $colums) { echo '<td> </td>'; $count += 1; } echo '</tr></table>'; Code (markup):