I am using
foreach($row as $val)
{
echo "<td>$val</td>";
}
echo "</tr>\n";
to generate a table row from my query. That works great as long as I don't have too many columns in the query, but once it gets larger then it causes the output to scroll horizontally and messes up my page layout.
I am wondering how I could change this - basically if I know I am querying on 15 columns but can only fit about seven columns how could I fix this to put a "</tr><tr><td>Continued</td>" in between value 7 and value 8? Do I need to do an i counter and increment it or what? If so what am I counting?
Here is the code I use now:
while ($row = mysqli_fetch_assoc($result))
{
if (!$heading) //only do if header row hasn't been output yet
{
$heading = TRUE; //so we only do this once
echo "<table>\n<tr>\n";
foreach ($row as $key =>$val)
{
echo "<th>$key</th>";
}
echo "</tr>\n";
}
if ($style=="odd") //set rows as even and odd
$style = "even";
else
$style = "odd";
echo "<tr class=\"$style\">";
foreach($row as $val)
{
echo "<td>$val</td>";
}
echo "</tr>\n";
}//close while
echo "</table>\n";
}