title: PHP Script for Datepicker to select and display database from Mysql
body: <p>After spending 3 days on internet and struggling with so many different forums , i have found a match and similar case of my problem here.</p>
  
  <p>Friends, I am zero in PHP, but still i have managed to do something to fulfill my requirement.</p>
  
  <p>I am stuck with one thing now..So i need help on....</p>
  
  <p>I am using one html+php form to submit database into mysql.
  I created a display of that table through php script on a webpage.
  Now i want a datepicker option on that displayed page by which i should able to select the date range and display the data of that date range from my mysql table.
  And then take a export of data displayed of selected date range in excel.</p>
  
  <p>This displayed page is login protected, so i want after login the next thing comes in should show a sate selection option which should be fromdate to to date , and then records should displayed from the database and i can take export of those displayed results in excel file.
  The code i am using on this page is below which do not have any thing included for excel export and date picker script, I am pasting the code here and request you to please include the required code in it as required.</p>
  
  <p>Thanks In advance</p>
  
  <pre><code>&lt;?php
  //database connections
  $db_host = 'localhost';
  $db_user = '***********';
  $db_pwd = '*************';
  
  $database = 'qserves1_uksurvey';
  $table = 'forms';  
  $file = 'export';
  if (!mysql_connect($db_host, $db_user, $db_pwd))
      die("Can't connect to database");
  
  if (!mysql_select_db($database))
      die("Can't select database");
  
  // sending query
  $result = mysql_query("SELECT * FROM {$table} ORDER BY date desc");
  if (!$result) {
      die("Query to show fields from table failed");
  }
  $num_rows = mysql_num_rows($result);
  $fields_num = mysql_num_fields($result);
  
  echo "$num_rows"; 
  echo "&lt;h1&gt;&lt;/h1&gt;";
  echo "&lt;table border='1'&gt;&lt;tr&gt;";
  // printing table headers
  for($i=0; $i&lt;$fields_num; $i++)
  {
      $field = mysql_fetch_field($result);
      echo "&lt;td&gt;{$field-&gt;name}&lt;/td&gt;";
  }
  echo "&lt;/tr&gt;\n";
  // printing table rows
  while($row = mysql_fetch_row($result))
  {
      echo "&lt;tr&gt;";
  
      // $row is array... foreach( .. ) puts every element
      // of $row to $cell variable
      foreach($row as $cell)
          echo "&lt;td&gt;$cell&lt;/td&gt;";
  
      echo "&lt;/tr&gt;\n";
  }
  mysql_free_result($result);
  ?&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>