0

Everytime I pass post array data it overwrites itself every time a new selection is passed. I want it to add to the previous selection and keep growing.

Im banging my head trying to work this out, is it due to the array thats passed not having enough dimensions or the right key??

echo '<input type="checkbox" id ="menu" name="'.$did.'['.$result2['cid'].']'.'['.$result2['id'].']" value="'.$result2['id'].'">'.ucwords($result2['name']).'<br />';
if($array){    
    foreach ($array as $key => $value){        
        if(is_array($value)){
            foreach ($value as $key => $value){
                $query = mysql_query("SELECT title FROM menuCategory WHERE cid = $key");
                $result = mysql_result($query,0);                      
                echo '<h1>'.ucwords($result).'</h1>';             
                foreach ($value as $key => $value){
                    echo '<input type="hidden" name="'.$key.'" value ="'.$value.'">';  
                    $query = mysql_query("SELECT cid, id, name FROM menuBread WHERE id = $value");
                    $result = mysql_fetch_assoc($query);
                    echo ucwords($name = $result['name']).'<br />';
                }                   
            } 
        } 
    }
}
0

1 Answer 1

6

You are using the same variable names for both the inner and outer foreach loops which is overwriting the variables....

Change the names in one of the places, and you should be good.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.