reciving eather value for the navigation menu in php
<p>I have two navigation one is in the header and the other is in the same page, now what i want is to do is be able to pull all the data from the table product a specific product from the sub category when i click the sub category. what i have now, is when i click on the menu that is on the header page that i have included in every page  i get the product listed but the menu that is on product page produce an error that the foreach is empty. when i use my other function to pull all the sub category it works fine but i want to pull only the sub category that belong to that particular main category. the code bellow will make more sense. </p>

<p>header Page:</p>

<pre><code>&lt;?php 
error_reporting(E_ALL);
ini_set('display_errors','1');?&gt;
&lt;?php require_once("initi.php");?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;/title&gt;
 &lt;link rel="stylesheet" href="css/reset.css" /&gt;
 &lt;link rel="stylesheet" href="css/main.css" /&gt;
 &lt;link rel="stylesheet" href="css/footer.css" /&gt;
&lt;script type="text/javascript" src="/ghaniya.com/javascript/jqu.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(document).ready(function(){
$(".logbtn").click(function(){ 
      $("#login2").hide("show");
      $("#login1").slideToggle("slow");
      $(this).toggleClass("active");

});

$(".logbtn2").click(function(){ 
      $("#login1").hide("show");
      $("#login2").slideToggle("slow");
      $(this).toggleClass("active");      
});
});
&lt;/script&gt;
&lt;style type="text/css"&gt;

div#login1{
background-color:#efebee;
margin:0 auto;
width:100%;
display:none;
height:100px;
}

div#login2{
background-color:#f5dce4;
margin:0 auto;
width:100%;
display:none;
height:100px;
}
.size{width:960px; }
.flotl{float:left; font-size:11px; text-decoration:none; height:30px; margin-left:20px;}
div#centerl{ width:960px; margin:0 auto; }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="head"&gt;

&lt;div class="size center"&gt;
&lt;img src="img/logosmall.png"&gt;
&lt;ul id="mainLink"&gt;
&lt;li&gt;&lt;a class="logbtn"&gt;Women&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="logbtn2" href="#"&gt;man&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#"&gt;Beauty&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=""&gt;Gifts&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=""&gt;Perfumes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div id="loginBox"&gt;
&lt;h3&gt;REGISTER | SIGN IN&lt;/h3&gt;
&lt;/div&gt;

&lt;div id="search"&gt;
&lt;input type="submit"/&gt;&lt;input type="text" value="Search"/&gt;
&lt;/div&gt;
&lt;div id="bag"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;


&lt;div id="login1" &gt;
&lt;div id="centerl"&gt;
&lt;ul class="flotl" &gt;
&lt;?php
$cata = Catagory::find_all(); 
foreach($cata as $catag){?&gt;
      &lt;li&gt;&lt;a href="/ghaniya.com/product.php?catid=&lt;?php echo $catag-&gt;catagory_id;?&gt;"&gt;&lt;?php echo $catag-&gt;name; ?&gt;&lt;/a&gt;&lt;/li&gt;
&lt;?php }?&gt;
&lt;/ul&gt; 
&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Product Page:</p>

<pre><code>&lt;?php require_once("includes/head.php"); ?&gt;
&lt;?php
  $cata_id = "";  
  $subcat ="";
  if(isset($_GET['catid']))
    {
         $cata_id = $_GET['catid'];
         $product = Product::find_by_cata_id($cata_id);
    }
    elseif(isset($_GET['subcat']))
    {
    $subcat =$_GET['subcat'];
    $subcat = SubCata::find_by_cata_id(1);
    print_r($subcat);
    }
?&gt;
&lt;div class="cBoth"&gt;&lt;/div&gt;
&lt;div id="contentEveryWhere" class="center"&gt;
&lt;div id="cata"&gt;
&lt;div id="leftNoticeBoard"&gt;&lt;/div&gt;
&lt;ul id="catagories"&gt;
&lt;h1&gt;CLOTHING&lt;/h1&gt;
&lt;?php foreach($subcat as $sub){ ?&gt;
&lt;li&gt;&lt;a href="product.php?subcat=&lt;?php echo $sub-&gt;subcata_id; ?&gt;"&gt;&lt;?php echo $sub-&gt;name; ?&gt;&lt;/a&gt;&lt;/li&gt;
&lt;?php } ?&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id="products"&gt;
&lt;div id="catatitle"&gt; 
&lt;ul&gt;
&lt;li&gt;Home &gt;&lt;/li&gt;&lt;li&gt;Women &gt;&lt;/li&gt;&lt;li&gt;Coat&lt;li&gt;
&lt;/ul&gt;
&lt;h1&gt;Coat&lt;/h1&gt;
&lt;p class="floatl"&gt;Sort items by Price: High | Low View as: &lt;img src="#" alt="icon png"/&gt; |&lt;img src="#" alt="icon png"/&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;ul id="product"&gt;
&lt;?php $product = Product::find_by_cata_id($cata_id);?&gt;
&lt;?php foreach($product as $pro){?&gt;
&lt;?php $image = Image::find_by_product_id( $pro-&gt;product_id);?&gt;
          &lt;li&gt;
               &lt;?php if(isset($image-&gt;filename)){ ?&gt;
               &lt;img src="/ghaniya.com/img/products/&lt;?php echo $image-&gt;filename;?&gt;"/&gt;
               &lt;?php } ?&gt;

              &lt;h2&gt;&lt;?php echo $pro-&gt;name;?&gt;&lt;/h2&gt;
              &lt;h3&gt; &lt;?php echo $pro-&gt;product_desc;?&gt;&lt;/h3&gt;
              &lt;h4&gt;&lt;?php echo $pro-&gt;price;?&gt;&lt;/h4&gt;
          &lt;/li&gt;
&lt;?php } ?&gt;
&lt;/ul&gt;&lt;!--end of product list--&gt;
&lt;/div&gt; &lt;!--end of products div--&gt;



&lt;/div&gt;&lt;!--end of contentEveryWhere div--&gt;
&lt;div class="cBoth"&gt;&lt;/div&gt;
&lt;?php require_once("includes/footer.php"); ?&gt;
</code></pre>

<p>Warning: Invalid argument supplied for foreach() in /Users/mughery/Website/ghaniya.com/product.php on line 25</p>
