problem in Associative arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manpreet_jsb
Forum Newbie
Posts: 3
Joined: Fri Apr 04, 2008 12:14 pm

problem in Associative arrays

Post by manpreet_jsb »

i have code

<?php
//storing default menu path like this in arrary---» Homepahe » Products »
$link1_array = array("Homepage" => "index.php", "Products" => "products.php");
function addValue(){
global $link_array;
$l = count($link_array);
$link1 = array($_REQUEST[val] => $_SERVER['REQUEST_URI']);
array_splice($link_array, $l+1, $l, $link1);
echo '<pre>';
print_r($link_array);
echo '</pre>';
}
?>
<table width='846' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>
<tr>
<td height='24' bgcolor='#E9E9E9'><span style="padding-left:10px;"> <?php
// making path
foreach( $link_array as $key => $value){
echo " » <a href=$value>$key</a>" ;
}
?></span></td>
</tr>
</table>
<table width='100%' border='0' cellpadding='0' cellspacing='0' class='spebor'>
<tr>
<td style='background:url(images/intblebg.gif); background-repeat:repeat-x'><div id='sidebar'>
<div id='links'>
<ul>
<?php
include('connect.php');
if(isset($_REQUEST[id])){
$f = "parent='$_REQUEST[id]'";
addValue(); // calling fuction for add new menu in arrary
}else{
$f = "`parent` IS NULL ";
}
$result=queryinspect("SELECT id,caption FROM `menuitems` WHERE $f");
while($res=mysql_fetch_row($result))
{ ?>
<li><a href='products.php?id=<?php echo $res[0]; echo '&val='; echo $res[1];?>' ><?php echo $res[1] ?></a></li>
<?php } ?>

this page making main menu after click call same page but with SUBMENU anb again clicking on it opening same page with SUB SUB MENU...

in page i just want to show: » Homepage » Products » ARTEMA

one time its adding ok..in arrary
Array
(
[ana sayfa] => index.php
[ürünler] => products.php
[0] => /ermatas/products.php?id=1&val=ARTEMA
)
[0] value is not coming
but next tym in sub sub menu last value is replacing...why dont know.....can some body help to do it in rite way maybe other mathod.
Post Reply