ok, this has plagued me for along time. I think I found a solution than it doesn't work. what I am after is a way to control how many items to echo to the screen in a table row.
say I have a loop
echo"<tr>";
for ($i=0; $i<$num_links; $i++){
$row=$db_view->fetch($sql_result);
if ($i % 2) {
echo"<td>item here</td>";
echo"</tr><tr>";
} else {
echo"<td>item here</td>";
}
}
echo"</tr>";
now that will do 2 items per row. what if I made the 2 a variable and went to 3 or 4? it always comes back 2 items per row.
so how do I make it so I can get controlled amount of items per row?ahh my logic was backwards, I fixed it.
echo"<tr>";
for ($i=0; $i<$num_links; $i++){
$row=$db_view->fetch($sql_result);
if ($i % 2) {
echo"<td>item here</td>";
} else {
echo"</tr><tr>";
echo"<td>item here</td>";
}
}
echo"</tr>";
say I have a loop
echo"<tr>";
for ($i=0; $i<$num_links; $i++){
$row=$db_view->fetch($sql_result);
if ($i % 2) {
echo"<td>item here</td>";
echo"</tr><tr>";
} else {
echo"<td>item here</td>";
}
}
echo"</tr>";
now that will do 2 items per row. what if I made the 2 a variable and went to 3 or 4? it always comes back 2 items per row.
so how do I make it so I can get controlled amount of items per row?ahh my logic was backwards, I fixed it.
echo"<tr>";
for ($i=0; $i<$num_links; $i++){
$row=$db_view->fetch($sql_result);
if ($i % 2) {
echo"<td>item here</td>";
} else {
echo"</tr><tr>";
echo"<td>item here</td>";
}
}
echo"</tr>";