I have a search form below, which has two types of input types and one text input field where the user can search by keywords. For some reason, whenever I click on the keywords text box, the focus immediately changes to the first drop-down list for the category and me, so I canβt enter anything into the keywords text box. Can anyone understand why this is happening?
$categories_list = array(); $ratings_list = array(); try { $query = $dbh->query("SELECT category, genre, rating FROM posts WHERE 1 GROUP BY category, genre, rating"); $query->setFetchMode(PDO::FETCH_ASSOC); $iterator = new IteratorIterator($query); foreach ($iterator as $row) { if (empty($row['category']) == false && !in_array($row['category'], $categories_list)) $categories_list[] = $row['category']; if (empty($row['rating']) == false && !in_array($row['rating'], $ratings_list)) $ratings_list[] = $row['rating']; } } catch (Exception $e) { echo '<p>', $e->getMessage(), '</p>'; } ?> <p> </p> <p> </p> <h2>Search Completed Stories</h2> <form name="search" method="get" action="http://example.com/searchB/"> <label> Category: <select name="category"> <?php foreach($categories_list as $category) : ?> <option><?php echo $category; ?></option> <?php endforeach; ?> </select> </label> <label> Rating: <select name="rating"> <option value="">Any</option> <?php foreach($ratings_list as $rating) : ?> <option><?php echo $rating; ?></option> <?php endforeach; ?> </select> </label> <label> Keywords: <input type="text" name="keywords"> </label> <input type="hidden" name="active" value="0"> <input type="submit"/>
source share