Hi,
Need help with my simple PHP menu. I'd like to have something like that: when child elements < 6 display one column if > 6 display two columns. Any advices how to make it?
Regards
Hi,
Need help with my simple PHP menu. I'd like to have something like that: when child elements < 6 display one column if > 6 display two columns. Any advices how to make it?
Regards
If sub menu contains more than 6 links I like submenu looks like:
Link
Link
Link
Link
If more than 6 links:
Link Link
Link Link
Link Link
I'm using WP, just need advice how to make it.
Here's the basic idea, you can adapt it to work with a table:
if (count($childs) < 6)
{
foreach ($childs as $child)
{
echo htmlspecialchars($child)."<br>";
}
}
else
{
for ($n=0;$n<count($childs);$n++)
{
echo htmlspecialchars($child)." ";
if ($n%2) echo "<br>";
}
}
For a table:
if (count($childs) < 6)
{
// Single row
echo "<tr>";
foreach ($childs as $child)
{
echo "<td>".htmlspecialchars($child)."</td>";
}
echo "</tr>";
}
else
{
// Multiple row
echo "<tr>";
for ($n=0;$n<count($childs);$n++)
{
echo "<td>".htmlspecialchars($child)."</td>";
if ($n%2) echo "</tr><tr>";
}
echo "</tr>";
}
There are other ways.