select Posted November 5, 2009 Share Posted November 5, 2009 Hi, I am trying to do a dynamic menu based on page id. This is what I got: $id = clean($_GET['id']); $current_page = $id; if($current_page == $id) { echo 'id="here"'; } This is how I get the menu from the database: while($row = mysql_fetch_assoc($result) ) { echo "<li>" . "<a href=" . $row['mlink'] . " title=" . $row['mtitle'] . ">" . $row['mname'] . "</a>" . "</li>"; } Can I somehow work the if $current_page statement into the <a> tag and assign the id to the link? Link to comment https://forums.phpfreaks.com/topic/180407-dynamic-menu-and-set-page-idhere/ Share on other sites More sharing options...
select Posted November 5, 2009 Author Share Posted November 5, 2009 I got first part working, but I see that this might not be the way to do it at all, since the id=”here” gets assigned to all the links all the time, because of the while loop I suppose. Link to comment https://forums.phpfreaks.com/topic/180407-dynamic-menu-and-set-page-idhere/#findComment-951784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.