title: $data is not returning result
body: <p>I need the $data to return from the database if the data was found from the database, but unfortunately, my code is not working to return the data.</p>
  
  <p>I tried to enter non-exist data, it managed to return the error message but if the data exist, the page displays nothing.</p>
  
  <p>May I know where did I go wrong in my if statement?</p>
  
  <p>Below is my code that contain after the $data return the script will execute.</p>
  
  <pre><code>$day  = $_POST['day']; 
  $month = $_POST['month']; 
  $year  = $_POST['year']; 
  $dob = implode('/', array($day,$month,$year)); 
  
  if(isset($_POST['submit'])){ 
      if(empty($_POST['day']) || empty($_POST['month']) || empty($_POST['year'])){ 
          echo "You need to fill in each field.&lt;br /&gt;&lt;br /&gt;&lt;a href=\"./\" title=\"Fill In Again\"&gt;Click here to &lt;b&gt;fill in each field&lt;/b&gt; again&lt;/a&gt;"; 
      exit; 
      } 
  } 
  
  //Date that user keyin 
  $userDate = $dob; 
  $dateTime = DateTime::createFromFormat('d/m/Y', $userDate); 
  $myFormat = $dateTime-&gt;format('Y-m-d'); 
  
  //Query string and put it in a variable. 
  if(isset($_POST['dob_chi'])){ 
      $query = "SELECT * FROM $table_n WHERE dob_chi = :date"; 
  } else { 
      $query = "SELECT * FROM $table_n WHERE dob_eng = :date"; 
  } 
  
  $stmt = $db-&gt;prepare($query); 
  $stmt-&gt;execute(array('date' =&gt; $myFormat)); 
  $data = $stmt-&gt;fetchAll(); 
  if ( !$data ) { 
      echo 'No data found in database!'; 
      exit; 
  } else { 
      return $data=$userDate; 
  } 
  
  //Now we create a while loop for every entry in our DB where the date is match. 
  while ($row = $stmt-&gt;fetchObject()) { 
      $r1          = $row-&gt;rowone; 
      $r2          = $row-&gt;rowtwo; 
      $r3          = $row-&gt;rowthree; 
      $englishdate = $row-&gt;dob_eng; 
      $chinesedate = $row-&gt;dob_chi; 
      $zodiac      = $row-&gt;zodiac; 
  
      //add all initial data into a matrix variable for easier access to them later 
      //To access rowone use $rows[0][0], rowtwo $rows[1][0] ect. 
      //The matrix is an array which contains multiple array. eg. 2-dimensional arrays 
      //To get all the variables with $r1X simply retrieve the first array of the matrix eg $rows[0] 
      $rows = array(array($r1),array($r2),array($r3),array());        
  } 
  //Similarities between row1 and row2 made me incorporate modulo value as an argument. 
  function incmod($a, $m){ 
      return ($a % $m) + 1; 
  }
  </code></pre>
  
  <p>Thank you for your time</p>