title: php display query results on same page
body: <p>Below is a form in my index page where user will select an option and click submit. On submitting it'll be posted in "display.php" file where i'm fetching data from database.</p>
  
  <p>index page code:</p>
  
  <pre><code>&lt;form action="display.php" method="post"&gt;
  &lt;select name="mnth"&gt;
  &lt;option value="Jan"&gt;January&lt;/option&gt;
  &lt;option value="Feb"&gt;February&lt;/option&gt;
  &lt;option value="Mar"&gt;March&lt;/option&gt;
  &lt;option value="Apr"&gt;April&lt;/option&gt;
  &lt;option value="May"&gt;May&lt;/option&gt;
  &lt;option value="Jun"&gt;June&lt;/option&gt;
  &lt;option value="Jul"&gt;July&lt;/option&gt;
  &lt;option value="Aug"&gt;August&lt;/option&gt;
  &lt;option value="Sep"&gt;September&lt;/option&gt;
  &lt;option value="Oct"&gt;October&lt;/option&gt;
  &lt;option value="Nov"&gt;November&lt;/option&gt;
  &lt;option value="Dec"&gt;December&lt;/option&gt;
  &lt;/select&gt;
  &lt;input id="abc" type="submit" name="Display"&gt;&lt;/input&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>The display.php file contains the following php code which fetches data from table and displays it in a tabular form in a different white page.
  But want to display this table in my index page instead. How do i do that?</p>
  
  <pre><code>&lt;?php
  
  $empid=$_COOKIE["empid"];
  $deptt=$_COOKIE["deptt"];
  $password=$_COOKIE["password"];
  
  $month=$_POST["mnth"];
  
  
  
  $empid=mysql_real_escape_string($empid);
  date_default_timezone_set('Asia/Kolkata');
  
  
  $con=mysql_connect("localhost","root","","");
  if(!$con)
  {
  die("Error in connection");
  }
  
  $db=mysql_select_db("swan",$con);
  
  if(!$db)
  {
   echo mysql_errno($con);
  }
  
  $query_login="SELECT * FROM `".$empid."_login` WHERE month='$month' ";
  $query_logout="SELECT * FROM `".$empid."_logout` WHERE month='$month' ";
  $query_hrs="SELECT * FROM `".$empid."_hrs` WHERE month='$month' ";
  $result1=mysql_query($query_login,$con);
  $result2=mysql_query($query_logout,$con);
  $result3=mysql_query($query_hrs,$con);
  $value1=mysql_fetch_array($result1);
  $value2=mysql_fetch_array($result2);
  $value3=mysql_fetch_array($result3);
  
  
  
  
  $day=date('d');
  
  echo '&lt;table id="displayTable" border="1px"&gt; &lt;th&gt;Date&lt;/th&gt;&lt;th&gt;Login_Time&lt;/th&gt;
        &lt;th&gt;Logout_time&lt;/th&gt;&lt;th&gt;Hours&lt;/th&gt;';
  
  
  for($i=0;$i&lt;31;$i++)
  {
  echo '&lt;tr&gt;&lt;td&gt;'.($i+1).'&lt;/td&gt;&lt;td&gt;'.$value1[($i+1)].'&lt;/td&gt;&lt;td&gt;'.$value2[($i+1)].'&lt;/td&gt;
  &lt;td&gt;'.$value3[($i+1)].'&lt;/td&gt;&lt;/tr&gt;';
  
  }
  
  echo '&lt;/table&gt;';
  
  
  
  ?&gt;
  </code></pre>