<?php
include 'connection.php';
if ($_POST['submit'] == 'Search'){
  $qry = $_POST['qry'];
  $sql = $dbh->prepare("select * from recipes where recipetitle like '%$qry%' or recipedescription like '%$qry%'");
  $sql->execute();
  while ($row = $sql->fetch()){
  	$id = $row['id'];
  	$title = $row['recipetitle'];
  	$descrip = $row['recipedescription'];
  	echo '<h5>'.$title.'</h5>';

 	$descarr = explode('.',$descrip);

 	for ($i=0;$i<2;$i++){
 	$desc .= $descarr[$i].'.';
   }

  	echo '<p>'.wordwrap($desc,100,'<br>').' <a href="recipe.php?id='.$id.'">Read More</a></p>';
}


}
?>




<form action = "search.php" method="post">
<input type="text" name="qry" /><br/>
<input type="submit" name="submit" value="Search">
</form>