ok as the title says, please take a look at the code im using:

```
$search=$_POST['search'];
$query = $pdo->prepare("select * from exportitems where partn LIKE '%$search%' OR manufacturer LIKE '%$search%'");
$query->bindValue(1, "%$search%", PDO::PARAM_STR);    
$query->execute();
if(isset($_POST['search']) || empty($_POST['search']))
{
echo "<center>WRITE SOMETHING IN THE SEARCH FIELD</center><br/>";
}
else if (!$query->rowCount() == 0) {
echo "<center>Search results</center><br/>";
echo "<table style=\"font-family:arial;color:#ffffff;\">";  
echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#000000;\">PART NUMBER</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;background:#000000;\">MANUFACTURER</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;background:#000000;\">DETAILS</td></tr>";             
while ($results = $query->fetch()) {
echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#000000;\">";            
echo $results['partn'];
echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;\">";
echo $results['manufacturer'];
echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;\">";
echo $results['details'];
echo "</td></tr>";
}
echo "</table>";        
} else {
echo "<center>NO RESULT FOUND</center><br/>";
}
?>

```

the problem im having appears when doing the query, it only executes:

```
if(isset($_POST['search']) || empty($_POST['search']))
{
echo "<center>WRITE SOMETHING IN THE SEARCH FIELD</center><br/>";
}

```

and ignores the rest, so no matter if the field is empty, or anything is written on it, it wont execute the code and get stuck on there.

BUT if i use this code only:

```
$query->execute();
if (!$query->rowCount() == 0) {
echo "<center>Search results</center><br/>";
echo "<table style=\"font-family:verdana;color:#ffffff;\">";    
echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#000000;\">PART NUMBER</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;background:#000000;\">MANUFACTURER</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;background:#000000;\">DETAILS</td></tr>";             
while ($results = $query->fetch()) {
echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#000000;\">";            
echo $results['partn'];
echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;\">";
echo $results['manufacturer'];
echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#000000;\">";
echo $results['details'];
echo "</td></tr>";
}
echo "</table>";        
} else {
echo "<center>NO RESULT FOUND</center><br/>";
}
?>

```

the search script will work properly EXCEPT for the fact that if the form search field have no characteres and the search button is pressed, the result will output the whole database as a result, making it a security flaw.

any idea of what i'm doing wrong??

thanks in advance.

p.s.: i searched for similar solutions on the community BUT nothing appeared to be this specific case.