PHP function call from form not working

kubiix

New Member
Guys, I'm trying to call a function from a form within the same .php file, but when the Submit button is hit, the table doesn't get generated.Here's the code:\[code\]<p><?phpfunction selectQuery(){ $con = mysql_connect("localhost","readonly",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mediadb", $con); $result = mysql_query("SELECT title, director FROM movies WHERE year = '$_POST[year_txt]'"); echo "<table border='1' background='lightgray'> <tr> <th>Title</th> <th>Director</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['director'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con);}?></p><p><!-- start of entry form --><form action="index.php?action=selectQuery" method="post">Year: <input type="text" name="year_txt" /><input type="submit"/></form><!-- end of entry form --></p>\[/code\]Any idea why this isn't working?Thanks in advance, guys and gals!
 
Top