Hello all,
Is there an easy way to determine the last iteration of a while () loop? My suspicion is that there is no way until the while concludes. I was wondering because I'm using a very simple while() to create a list for use in my navigation, I need the last element in that list to have a class of "last" so that my css knows not to put a separator bar when it displays it in a horizontal list.
The code I have is this:
$content .= <<<EOF
<ul>
EOF;
$result1 = @mysql_query("SELECT * FROM `navigation` WHERE level = '1'");
while ($row = mysql_fetch_array($result1, MYSQL_ASSOC)) {
$parent_id = $row['id'];
$parent_text = $row['text'];
$parent_link = $row['link'];
$parent_type = $row['type'];
$content .= <<< EOF
<li><a href=$page$parent_link>$parent_text</a></li>
EOF;
}
$content .= <<<EOF
</ul>
EOF;
Which I'd like to return:
<ul>
<li><a href=/index.php>Home</a></li>
<li><a href=/members.php>Members</a></li>
<li><a href=/products.php>Merchandise</a></li>
<li><a href=/downloads.php>Downloads</a></li>
<li class="last"><a href=/photo/login.php>Member Login</a></li>
</ul>
Any thoughts?
Any and all advice / insight will be greatly appreciated. Thanks in advance!
~Jordan