Hey Everyone i got a little problem! I know its something simple but for some reason i can not figure it out (arrays are kicking my butt!)
I want the results to display like the following...
title 1 | title 2 | title 3 | title 4 |
Title 5 | title 6 | title 7 | title 8 |
But for some reason when the code runs it shows as the following...
t | i |
It spells out the title 1 and not the whole word for each cell of the table. What am i doing wrong?
$result = mysqli_query($con,"SELECT title FROM donuts");
$rows = 2;
$cols = ceil(count($result)/$rows);
$row = mysqli_fetch_array($result);
echo $result=$row['title'];
echo "<table border='1'>";
$i=0;
for($tr=1;$tr<=$rows;$tr++) {
echo "<tr>";
for($td=1;$td<=$cols;$td++) {
if (isset($result[$i])) {
echo "<td>".$result[$i]."</td>"; $i++;
}
}
echo "</tr>";
}
echo "</table>";
Note the table has no limit on how many columns there are just rows.
Link to working example http://lakeside.donavonscreativeinnovations.com/