title: Execute two query from mysql in same page by passing value in url
body: <p>I have created a page in php
  I want to show when user type in weektable.php it should show all the value i.e it should execute this query</p>
  
  <pre><code> $sql = "SELECT * FROM `battery`";
  </code></pre>
  
  <p>above query display all the value.</p>
  
  <p>and when user type in url weektable.php?sort=w it should execute this query </p>
  
  <pre><code> $sql = "SELECT * FROM battery WHERE date BETWEEN '".$week."' AND '" .$date."'";
  </code></pre>
  
  <p>above query display value between current date and one week before date.</p>
  
  <p>But I have no Idea how to do it.
  I want to do it without go to another page i.e I want show both the value in same page</p>
  
  <p>Below is my PHP code:</p>
  
  <pre><code>&lt;?php
  $hostdb = 'localhost';
  $namedb = 'my_db';
  $userdb = 'root';
  $passdb = 'root';
  
  try {
  
    $conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
    $conn-&gt;exec("SET CHARACTER SET utf8");      // Sets encoding UTF-8
  
  
  $currDate = date('Y-m-d H:i:s');
  $date = $currDate ;
  // parse about any English textual datetime description into a Unix timestamp
  $ts = strtotime($date);
  // calculate the number of days since Monday
  $dow = date('w', $ts);
  //$offset = $dow - 3;
  $offset = $dow - date('d');
  if ($offset &lt; 0) {
      $offset = 6;
  }
  // calculate timestamp for the Monday
  $ts = $ts - $offset*86400;
  // loop from Monday till Sunday
  for ($i = 0; $i &lt; 1; $i++, $ts += 86400){
      //print date("Y-m-d l", $ts) ."&lt;/br&gt;" . "\n";
  $week = date("Y-m-d H:i:s", $ts) ."&lt;/br&gt;";
  
  }
  
          $sql = "SELECT * FROM `battery`";
          $sql = "SELECT * FROM battery WHERE date BETWEEN '".$week."' AND '" .$date."'";
  
  
    $result = $conn-&gt;query($sql);
  
  echo "&lt;table border='1' style='font-family:arial;font-size12px;' cellspacing=1&gt;
  &lt;tr&gt;
  &lt;th&gt;User Id&lt;/th&gt;
  &lt;th&gt;Firstname&lt;/th&gt;
  &lt;th&gt;LastName&lt;/th&gt;
  &lt;th&gt;EmailId&lt;/th&gt;
  &lt;th&gt;Date&lt;/th&gt;
  &lt;/tr&gt;";
  
    while($row = $result-&gt;fetch(PDO::FETCH_ASSOC)) {
    echo "&lt;tr&gt;";
  
    echo "&lt;td&gt;" . $row['id'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['firstname'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['lastname'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['emailid'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['date'] . "&lt;/td&gt;";
  
    echo "&lt;/tr&gt;";
    }
  
  echo "&lt;/table&gt;";
  
  } catch(PDOException $e) {
      echo 'ERROR: ' . $e-&gt;getMessage();
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>Please I need help.
  Any Help will be greatly appreciated.</p>