I have a dropdown menu populated from the MySQL database in a form. When I hit submit I want the results of the selection to be displayed... but I can't get it.
FORM CODE:
<form action="comic_index_view.php" method="post">
<?php
$result = mysql_query("SELECT title FROM comics GROUP BY title") or die(mysql_error());
$options="";
echo "<select>";
while($row = mysql_fetch_array($result)){
$title=$row["title"];
echo "<option value'" . $title . "'>".$title.'</option>';
}
echo "</select>";
?>
<input type="submit" name="submit">
</form>
RESULTS PAGE:
<?php
require('get_connected.php');
$title = $_POST['title'];
$sql = mysql_query("SELECT title, issue_number, cover_date, comic_id FROM comics WHERE title ='" . $title . "'") or die(mysql_error());
if ($result = mysql_query($sql)) {
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_assoc($result)) {
echo $row['title'];
}
}
}
echo $row['title'] . "<br>";
?>
I know this is a common thing people do with PHP but I could not find any info on the web. Can any one suggest a possible solution?
Thank you.