I have a php function that gets a list of authors from a database...I am trying to get this list to display on a drop down menu, so when the user goes to select by Author it shows up as a list of Authors form the data base...I don't want to input the authors manually but I want it to use the function to populate the list..Here is my getAuthors function
<?php
function getAuthors($db, $isbn)
{
$query = 'SELECT first_name, last_name
FROM books_authors
INNER JOIN authors ON authors.author_id = books_authors.author_id
WHERE isbn = :isbn
ORDER BY author_ordinal';
$statement = $db->prepare($query);
$statement->bindValue(':isbn', $isbn);
$statement->execute();
$authors = $statement->fetchAll();
$statement->closeCursor();
$authorString = "";
$count = 1;
foreach ($authors as $author)
{
$authorString = $authorString . $author['first_name'] . ' ' . $author ['last_name'];
if ($count < $statement->rowCount())
$authorString = $authorString . ", ";
$count++;
}
return $authorString;
}
?>
and here is my drop down menu
<select name ="searchtype">
<option value="author"> By author: </option>