tablename = cases
file1
caption1
file2
caption2
file3
caption3
file4
caption4
file5
caption5
file6
caption6
I want to print out these fields 3 per line in a table, however sometimes there may not be a file 5 or 6, so I want the program to print out only the fields that have information in them. I want the final table print out if there was all six files to look something like this:
Code: Select all
<table>
<tr>
<td><?php echo $row["file1"]; ?> - <?php echo $row["caption1"]; ?></td>
<td><?php echo $row["file2"]; ?> - <?php echo $row["caption2"]; ?></td>
<td><?php echo $row["file3"]; ?> - <?php echo $row["caption3"]; ?></td>
</tr>
<tr>
<td><?php echo $row["file4"]; ?> - <?php echo $row["caption4"]; ?></td>
<td><?php echo $row["file5"]; ?> - <?php echo $row["caption5"]; ?></td>
<td><?php echo $row["file6"]; ?> - <?php echo $row["caption6"]; ?></td>
</tr>
</table>Code: Select all
<table>
<tr>
<td><?php echo $row["file1"]; ?> - <?php echo $row["caption1"]; ?></td>
<td><?php echo $row["file2"]; ?> - <?php echo $row["caption2"]; ?></td>
<td><?php echo $row["file3"]; ?> - <?php echo $row["caption3"]; ?></td>
</tr>
<tr>
<td><?php echo $row["file4"]; ?> - <?php echo $row["caption4"]; ?></td>
</tr>
</table>