Here's my code:
<form action="" method="post">
<fieldset>
Date 1: <input type="text" name="date1">
Date 2: <input type="text" name="date2">
</fieldset>
<button type="submit" name="Search">
</form>
<?php
try {
$db = new PDO('mysql:host=localhost;dbname=db;charset=utf8', 'user', 'pass');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $e) {
echo "DB is down";
exit;
}
try {
$results = $db->query("SELECT * FROM instructor WHERE date_hired BETWEEN ? AND ?");
} catch (Exception $e) {
echo "No data found";
exit;
}
echo "<pre>";
var_dump($results->fetchAll(PDO::FETCH_ASSOC));
?>
How would I change the PHP code to use the form that I have created to take parameters?
I want to be able to enter 2 dates into the form, so it goes into the query, then output the results.