PHP not returning data from form
<p>this is going to drive me mad, because its probably something I have missed but I have a form that the user selects a country and a league name, and returns a table of the found results. </p>

<p>The problem I am having is that if that search form is submitted it returns nothing, but if I just refresh the page as normal with no submit it works fine and returns all the results. As you can see below it sets the $subleaguesearch and $countrysearch variables if the form has not been submitted and thats working fine, its just when it has been submitted that is not, and I just can't seem to find why. Any help would be great! thanks.</p>

<p>p.s I am receiving no error message its just not returning anything at all. And I have echoed the variables back to screen after the form submittion and they echoed back with the correct values so I know the variables are being set ok!.</p>

<pre><code>       &lt;form action="" method="post" autocomplete="off"&gt;
        &lt;table id="searchsubleaguetable" width="670px" align="left" cellpadding="1" cellspacing="0"&gt;    
                    &lt;tr colspan="2"&gt;
                    &lt;th colspan="2" align="left"&gt;&lt;label&gt;SEARCH SUBLEAGUES&lt;/th&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                    &lt;td align="right"&gt;&lt;label&gt;COUNTRY&amp;nbsp;&amp;nbsp;&lt;/td&gt;
                    &lt;td align="left"&gt;&lt;SELECT NAME="country" style="font-size:12px; padding:4px;"&gt;&lt;OPTION VALUE="0"&gt;All Countries&lt;?php echo $options;?&gt;&lt;/option&gt;&lt;/SELECT&gt;&lt;/label&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                    &lt;td align="right"&gt;&lt;label&gt;SEARCH&amp;nbsp;&amp;nbsp;&lt;/td&gt;
                    &lt;td align="left"&gt;&lt;input class="searchinputs" type="text" name="subleaguesearch" size="40" value=""&gt;&lt;/label&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr width="100%" height="20px" colspan="2"&gt;
                    &lt;td align="right"&gt;&lt;label&gt;&lt;/td&gt;
                    &lt;td align="left"&gt;&lt;input class="searchbutton" type="submit" value="Search" name="searchsubnow"&gt;&lt;/label&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
            &lt;/form&gt;




      if (isset($_POST['searchsubnow'])){
           $subleaguesearch = mysql_real_escape_string($_POST['country']);
           $countrysearch = mysql_real_escape_string($_POST['subleaguesearch']);        
           if($countrysearch == 0){
           $countrysearch = "%%";
           }
        }else{
           $subleaguesearch = "";
           $countrysearch = "%%";
        }

        $rowsPerPage = 15;
        $pageNum = 1;

        if(isset($_GET['page'])){
            $chosenpage = mysql_real_escape_string($_GET['page']);
            $pageNum = $chosenpage;
        }

        $offset = ($pageNum - 1) * $rowsPerPage;

        $result = mysql_query(" SELECT s.league_id, s.leaguename, s.private, s.date, u.flag, u.firstname, u.country,
                                COALESCE(SUM(r.total_points),0) as totalpoints,
                                count(m.member_id) participants
                                from sub_leagues s
                                Left Join members_leagues m
                                On m.league_id = s.league_id  
                                Left Join member_results r
                                On r.member_id = m.member_id
                                join members u
                                on s.admin = u.member_id
                                WHERE u.country LIKE '$countrysearch'
                                AND s.leaguename LIKE '$subleaguesearch%'
                                Group By s.league_id
                                Order By r.total_points DESC, participants DESC, s.date ASC " . " LIMIT $offset, $rowsPerPage") 
                        or die ("&lt;br/&gt;&amp;nbsp;Error - could not display league");
</code></pre>
