/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Navigation works only 1:2 times…

I Have a question about 2 scripts of mine.

I found a script on internet, which works nicely:
[URL=http://iceblade.mybesthost.com/tocmenu-srv/]http://iceblade.mybesthost.com/tocmenu-srv/[/URL]
When you click on a [+] it expands, and when you click again it collapses again. (watch the coloring of the text)

(see Original’s folder for 2 main files)
tocTab.php3 has an array(array(var,var,var),array(var,var,var)); in it, manually coded.

I rewrote the tocTab.php file so that it reads my database,
and creates the array(array(var,var,var),array(var,var,var)); dynamicly.
The menu shows the results as follows:
[URL=http://iceblade.mybesthost.com/Website/index.php?page.php?]http://iceblade.mybesthost.com/Website/index.php?page.php?[/URL]
The menu loads correctly, but when you open the [+] and click in one of the sublevels the top level doesn’t get deselected.

(My versions of the dynamic files are in the Dynamic folder.)

The problem is probably in tocTab.php But I can’t find where.
The array was a pain in the neck to create and eventhough it works something is still wrong. Please help me, I’m getting stressed after 4 days of straining over this bit of code.? It’s probably a really small error somewhere, but the fact that I can’t find it is unnerving.

Thank you for your time!
Maurice

[upl-file uuid=05b8722a-1746-4925-b108-e16a6277c20d size=6kB]menus.zip[/upl-file]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@DJsACauthorOct 17.2004 — Never mind.

After 6 days of staring my eyes out at the code I finally got it fixed...

[code=php]$tocTabArray = array();
array_push($tocTabArray, array((0), ("Verpakking Materialen Catalogus"), ("index.php?"."main".":"."n"."."."a"."."."500")));
$rowscat = mysql_num_rows(mysql_query("SELECT * FROM category"));
for($x=1; $x<$rowscat; $x++)
{
$query1 = mysql_query("SELECT * FROM category WHERE id = '$x'");
$category = mysql_fetch_object($query1);

array_push($tocTabArray, array(($x), ($category->CATEGORY), ("index.php?".$page.":".$resize.".".$scroll.".".$size."#".$article)));
$rows2 = mysql_num_rows(mysql_query("SELECT * FROM subcategory WHERE CATEGORY = '$x'"));
for($y=1; $y<$rows2; $y++)
{
$query2 = mysql_query("SELECT * FROM subcategory WHERE CATEGORY = '$x' AND placeinlist = '$y'");
$subcategory = mysql_fetch_object($query2);

array_push($tocTabArray, array(($x."-".$y), ($subcategory->SUBCATEGORY), ("index.php?".$page.":".$resize.".".$scroll.".".$size."#".$article)));
}
}[/code]
Should have been: [code=php]$tocTabArray = array();
array_push($tocTabArray, array("0", "Verpakking Materialen Catalogus", "index.php?main:n.a.500"));
$rowscat = mysql_num_rows(mysql_query("SELECT * FROM category"));
for($x=1; $x<$rowscat; $x++)
{
$query1 = mysql_query("SELECT * FROM category WHERE id = '$x'");
$category = mysql_fetch_object($query1);

array_push($tocTabArray, array("$x", "$category->CATEGORY", "index.php?$page:$resize.$scroll.$size#$article"));
$rows2 = mysql_num_rows(mysql_query("SELECT * FROM subcategory WHERE CATEGORY = '$x'"));
for($y=1; $y<$rows2; $y++)
{
$query2 = mysql_query("SELECT * FROM subcategory WHERE CATEGORY = '$x' AND placeinlist = '$y'");
$subcategory = mysql_fetch_object($query2);

array_push($tocTabArray, array("$x-$y", "$subcategory->SUBCATEGORY", "index.php?$page:$resize.$scroll.$size#$article"));
}
}[/code]

They give the same results, but somehow the array remembers the quotes eventhough it doesn't output them.

They both look exactly the same using print_r() but I guess somehow they're different.
×

Success!

Help @DJsAC spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...