Having trouble getting my PDO query to display on another page : <p>I have been working on learning PDO. Basically what I am trying to do is display names that are off work on any given day of the year. </p>

<p>I created a prepared statement that gives me the names, based on a date set in a variable. It's working as expected.</p>

<p>The problem I am having is displaying that on a seperate page. Lets say my page with the PDO statement is called vacationnames.php</p>

<p>Depending on the date I need to display those names on 1 of 4 different pages called calendar1.php or calendar2.php...etc.</p>

<p>Here is the code I have:
vacationnames.php</p>

<pre><code>$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE            =&gt; PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE =&gt; PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES   =&gt; false,
];
$db = new PDO($dsn, $user, $pass, $opt);

$sth = $db-&gt;prepare("
SELECT (employee.name)Name
, vacation_picks._date1 as Date
FROM employee
LEFT OUTER JOIN
vacation_picks on
employee.employee_id = vacation_picks.employee_id
WHERE vacation_picks._date1 = :day
");
</code></pre>

<p>This is on one of the calendar.php pages
    </p>

<pre><code>$myVariable = ('2017-1-1');
// This executes the SQL query, binding the parameter as we go.
$sth-&gt;execute(array(
':day' =&gt; $myVariable
));

// echo $myVariable;
foreach($sth as $row) { 
 echo $row['Name'];
} 
</code></pre>

<p>Even putting the 'Day One' php on calendar.php with vacationnames.php required_once gives me no result. I would prefer to have it referenced with even less code on calendar.php if possible.</p>

<p>Thanks for looking.</p>
