Hi there,
I try to figure out, how I can add links into the menu structure dynamically.
e.g:
Table "DODO" has this structure:
UserName | Category | Item
------------------------------
User01 | Cat_A | white Socks
User01 | Cat_A | white Shirt
User01 | Cat_A | white Pants
User01 | Cat_B | black Socks
User01 | Cat_B | black Shirt
....
User02 | Cat_foo | red trousers
User02 | Cat_foo | green trousers
And another Table "UserCat" just stores the categories a user has applied:
UserName | CatName
------------------
User01 | Cat_A
User01 | Cat_B
User02 | Cat_foo
Now I would like to dynamically add entries to the menu regarding to the User and categories
User01 should see
- Cat_A (linking to all entries in Cat_A from User01 -> The result of this link will display in a table "white Socks", "white Shirts", "white Pants)
- CAT_B (Linking to Cat_B from User01)
MENU
|
+- Cat_A
+- Cat_B
User02 should only see in the menu
- Cat_foo (red trousers, green trousers)
MENU
|
+- Cat_foo
Pseudo code for menueItemModify:
//Counting how much category a User has
$sql="SELECT COUNT(*) AS c FROM UserCat WHERE `userName` ='".$_SESSION["UserID"]."'"; // Count the entries from this User
$rs=CustomQuery($sql);
$data = db_fetch_array($rs);
//Store the names of the categories from the user
$strID = "SELECT DISTINCT CatName FROM userCat WHERE `userName` = '".$_SESSION["UserID"]."'";
$rsID = db_query($strID,$conn);
$dataID = db_fetch_array($rsID);
//Cycle through the categories (for User01 two times, for User02 only one time)
while ($i <= $data) {
*Print a link with the category name $dataID[$i] // For User01: Cat_A, Cat_B and for User02 only Cat_foo
}
I' guess I have to modify menueitem.php or displaymenu.php with a place holder/variable and assign the entries to this place holder to show the links inside the menu struckture...
I really hope you understand, what I mean...
thx,
mickna