I'm trying to create an HTML table like this, data comes from MySQL:
<table>
<tr>
<td>image1</td>
<td>image2</td>
<td>image3</td>
<td>image4</td>
</tr>
<tr>
<td>link</td>
<td>link</td>
<td>link</td>
<td>link</td>
</tr>
<tr>
<td>image5</td>
<td>image6</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>link</td>
<td>link</td>
<td> </td>
<td> </td>
</tr>
</table>
I need to use this loop: foreach (glob("$img", GLOB_BRACE) as $image). I now have this, but it doesn't format the table as I need. Who can help me?
$id = $_SESSION['id'];
$path = "a/";
$img = $path . $id . "_" . "*" . ".jpg";
$count = 0;
$count2 = 0;
echo "<table cellpadding=\"0\" cellspacing=\"5\"><tr>";
foreach (glob("$img", GLOB_BRACE) as $image) {
$count++;
list($w, $h) = getimagesize($image);
$image2 = str_replace('a/', 's/', $image);
$image3 = str_replace('a/', '', $image);
echo "<td class=\"td2\" align=\"center\">";
echo "<img src=\"$image2\" border=\"0\" onClick=\"MM_openBrWindow('showpic.php?img=$image3','','status=yes, width=$w, height=$h')\">";
echo "</td>";
if($count == 4){
echo "</tr><tr>";
foreach (glob("$img", GLOB_BRACE) as $image) {
$image4 = str_replace('a/', 's/', $image);
$count2++;
echo "<td class=\"td2\" align=\"center\">";
echo "$image4";
echo "</td>";
if($count2 == 4){
echo "</tr><tr>";
}
}
} if($count == 4){
echo "</tr><tr>";
}
}
}
echo "</tr></table>";