Hello,

I'm making a menu script that uses mysql, php and javascript to build a "on 
mouse over" dropdown menu to a page. I ran into some problems and would need 
help to get this working. (This is just the top level of the menusystem)

1. Get the toplevel links from DB, create array and put values there.

$sql ="SELECT * FROM x_menu WHERE menulevel = '1' ORDER BY 'id' ASC";
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
while ($num >= $cur) {
$row = mysql_fetch_array($result);
$id = $row["id"];
$menulevel = $row["menulevel"];
$linktext = $row["linktext"];
$linkurl = $row["linkurl"];
$toplevel =    array("$id", "$menulevel", "$linktext", "$linkurl");
$cur ++;
}

The first problem comes here. How can I create a different array at every 
iteration of the loop? Or how this should be done if the toplevel objects 
are echoed with foreach to the browser like this:

$TopLevelCounter = 1;
foreach ($toplevel as $value){
print "menuSyS.addItem('labelItem', '$toplevel[2]', $TopLevelCounter, 
$width, '$colour1', '#0000aa', '$colour2');\n";
$TopLevelCounter ++;
}

Now, because I just fill the same array again and again in the DB query all 
top level items finally contain the same text. So my question is how to 
query the DB and create the arrays so that it would be easy to refer to the 
data in the arrays when printing to screen. Do I have to make 
multidimensional arrays? If so how to implement them here and how they 
should be referred to when printing to browser?

Thanks
-Will 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to