I'm making a page to register damage mobile phones. I made a search query to search data in database which matched datepicker's date. Here is my source code. (Only relevant to this question, )
<?php
 $con = mysql_connect("localhost", "root", "");
if ($con) {
$db = mysql_select_db('mobile', $con);
 } else {
die('Could not connect: ' . mysql_error());
}
 if (array_key_exists('myday', $_POST)) {
$mydate = $_POST['mydate'];
$myday = "SELECT * FROM mobile_rep WHERE sdate='{$mydate}' ";
}
 mysql_close($con)
  ?>
<html>
<head> </head>
<body>
<form action="index.php" method="POST" class="form-inline">
  <div class="span12" style="border-radius: 5px; border-style: solid; border-width: 1px; margin-left: 20px;" >
    <h5 style="margin-left: 10px; "> <b> Current User List </b></h5>
    Select By Date
    <input type="date" name="mydate" id="mydate" class="input-medium" />
     
    <input type="submit" class="btn-primary  " name="myday" value="Search by date" id='myday' />
    <br/> <br/>
    <table border="1" width="300" cellspacing="1" cellpadding="1" class="table table-striped" style=" border-radius: 5px; border-style: solid; border-width: 1px; ">
      <thead>
      <tr>
        <th>sdate</th>
        <th>model_no</th>
        <th>fault</th>
        <th>rp_fee</th>
        <th>sp_fee</th>
        <th>total</th>
      </tr>
      </thead>
      <tbody>
      <?php
      while ($row1 = mysql_fetch_array($myday)) {
        echo "<tr>";
        echo "<td>" . $row1['sdate'] . "</td>";
        echo "<td>" . $row1['model_no'] . "</td>";
        echo "<td>" . $row1['fault'] . "</td>";
        echo "<td>" . $row1['rp_fee'] . "</td>";
        echo "<td>" . $row1['sp_fee'] . "</td>";
        echo "<td>" . $row1['total'] . "</td>";
        echo "</tr>";
      }
      ?>
      </tbody>
    </table>
  </div>
</form>
</body>
</html>
 And I'm having 
Undefined variable: myday in C:\wamp\www\mobile\index.php on line 227 
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\wamp\www\mobile\index.php on line 227 
 
Line 227 means while ($row1 = mysql_fetch_array($myday)) { 
 
I also uploaded an image of my page too. 
 
 
Please help me.