Perhaps try this?
Code:
//the way this table works, it starts with one, not zero, so first declare a null value for "boxes[0]"
$boxes[0] = "";
// now each smiley should be saved as a "box"
foreach ($smilie as $key => $val) {
$boxes[] = "<td width=\"17\"><img src=\"$val\" alt=\"$key\" title=\"$key\" onclick=\"insert_smilies ('$key')\" /></td>\n";
}
// This table will have four columns and as many rows as you need.
$cols = 4;
$rows = ceil(count($boxes) / $cols);
$i = 1;
$j = 1;
echo ("<table border='2' align='center'>\n");
while ($i <= $rows) {
echo "\t<tr class='row$i'>\n";
while ($j <= $i * $cols) {
if (!isset($boxes[$j])) {
$boxes[$j] = " ";
}
echo ("\t\t<td id='box$j' >".$boxes[$j]."</td>\n");
$j++;
}
if ($j > $i * $cols) {
echo ("\t</tr>\n");
$i++;
}
}
echo ("</table>\n\n<br/><br/>\n\n");
Bookmarks