I generated a navigation menu for each user stored in my database. Each link redirects the user to an external web page.
Example of my menu:
John
Personal Information
Account Information
Family Members
Ann
Personal Information
Account Information
Family Members
<?php
foreach($users->results() as $user){
echo
'<li>
<a href="javascript:void(0);" title="Users">
<span>' . $user->userName . '</span>
</a>
<div class="sidebar-submenu">
<ul>
<li><a href="personalInfomation.php" title="Personal Information"><span>Personal Information</span></a></li>
<li><a href="accountInformation.php" title="Account Information"><span>Account Information</span></a></li>
<li><a href="familyMembers.php" title="Family Members"><span>Family Members</span></a></li>
</ul>
</div>
</li>';
}
}
?>
As you can see I have 3 PHP files and their purpose is to display data back to the user. Since all sub-menu pages are identically generated, they will be displaying the SAME data back to the user.
So I was wondering if there is a way to I could tweak my code so when a user clicks John->Personal Information, only John's personal information will be displayed.
I thought about saving the user_id (PK) inside in the a tag's value attribute and somehow retrieving it...later on.
<li>
<a href="personalInfomation.php" title="Personal Information" value="' . $user->user_id .'">
<span>Personal Information</span>
</a>
But it seems really inefficient and may be a big security flaw.
Any suggestions are greatly appreciated, thank you.