I have posted a form to output data form database. I am having trouble within my if statement looking to echo all lines that my month form post == the month within my database i.e if my form post was 04 i want it to equal all data that == XXXX/04/XX and echo them all.
At the moment it is not returning anything as the date formats do not match
Thank you in advance.
if(isset($_POST['submit'])) {//form has been submitted
$search = new Page();
$search->sub_name = $_POST['sub_name'];
$search->location = $_POST['location'];
$search->date_from = $_POST['date_from'];
} ?>
<h2>
<?php echo $search->sub_name; echo " "; echo $search->location;?>
</h2>
<table class="bordered" cellpadding="1" cellspacing="1">
<thead>
<tr> <th>Course</th> <th>Dates</th> <th>Course Type</th> <th>Location</th><th>Price </th><th></th></tr>
</thead>
<?php
$pages = Page::find_all();
foreach($pages as $page){
if($search->sub_name == $page->sub_name && $search->location == $page->subject && $search->date_from == $page->date_one('m')) {
echo "<tbody><tr><td><a href=\"course.php?id=" . urlencode($page->id) . "#type\">" . nl2br($page->course_name) . "</a></td><td>" . nl2br($page->date_from) . "</td><td>" . nl2br($page->sub_name) . "</td><td>" . nl2br($page->subject) . "</td><td>" . nl2br($page->price) . "</td><td><a href=\"hbt_bookings.php?id=" . urlencode($page->id) . "#type\">Book>>></td>" ."</tr></tbody>";
}
}
?>
</table>