Hi all,

I have some code that works up to a point. Iy produces 2 rows, a header row and a data row for the result of a query.

What I want to do is make the code produces 2 columns, the left column for the header and the right column for the data.

This is what I have:

$numFields = mysql_num_fields($FailedList);

echo "<table>";
echo "<tr>";

    for($i = 0; $i < $numFields; $i++)
    {
    echo "<td>";
    echo mysql_field_name($FailedList,$i);
    echo "</td>";
    }
    echo "</tr>";

    while($row = mysql_fetch_row($FailedList))
    {
    echo "<tr>";
    for($i = 0; $i < $numFields; $i++)
    {
    echo "<td>$row[$i]</td>";
    }
    echo "</tr>";
    }
echo "</table>";

Does anyone know how I can do this?

Regards

Blackbox

    What does $FailedList (and $numFields) look like?

    Obviously you need to not finish the TR tag, but you're currently using two loops. If you could combine those into one loop and do each row at once, that would be what you're looking for, but it would appear to have a disadvantage ... you'd be making several separate DB calls (of course, it looks like you might be doing that already ...)

      Write a Reply...