<pre><?php
require_once('include/DB.php');
include_once('include/crud.php');
if (isset($_POST["action_Key"]))
{
$query ="SELECT c.courseID AS 'Course ID',
c.courseTitle AS 'Course Title',
c.original_price AS 'Original Price',
c.discounted_Price AS 'Disco Price',
c.coverImageURL AS 'Course Img Path',
c.mediumOfTeaching AS 'Medium of Teaching',
u.userName AS 'Teacher Name'
FROM tbl_course c INNER JOIN tbl_users u
ON c.userID=u.userID WHERE c.catID !=''";
if (isset($_POST["minimum_price_Key"],
$_POST["maximum_price_Key"]) &&
!empty($_POST["minimum_price_Key"]) &&
!empty($_POST["maximum_price_Key"]))
{
$query .= "AND c.discounted_Price BETWEEN '" . $_POST["minimum_price_Key"] . "' AND '" . $_POST["maximum_price_Key"] . "'";
}
if (isset($_POST["mediumofTeaching_Key"]))
{
$medium_filter = implode("','", $_POST["mediumofTeaching_Key"]);
$query .= "AND c.mediumOfTeaching IN('" . $medium_filter . "')";
}
if (isset($_POST["difficultyLevel_Key"]))
{
$difficultyLevel_filter = implode("','", $_POST["difficultyLevel_Key"]);
$query .= "AND c.mediumOfTeaching IN('" . $difficultyLevel_filter . "')";
}
$statement = $pdoObj->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$total_row = $statement->rowCount();
$filteredCourses = '';
if ($total_row > 0)
{
foreach ($result as $row)
{
$filteredCourses .= '<div class="card" style="margin-top: 2%;">
<img class="card-img-top" src="'.str_replace("./","Teacher/",$row['Course Img Path']) . '" alt="Card image cap">
<div class="card-body">
<h5 class="card-title" style="height: 70px; text-align:justify;">'. $row['Course Title'] . '</h5>
<p class="card-text text-muted" style="text-align:justify;height: 67px;">';
if(isset($row['Short Desc']))
{
if(strlen($row['Short Desc'])<=120)
{
echo $row['Short Desc'];
}
else
{
echo substr($row['Short Desc'],0,120) . "...";
}
}
else
{
}
'</p>
<table class="card-footer" style="margin-top: 20px;border-bottom: 1px solid lightgray;border-left: 1px solid lightgray;border-right: 1px solid lightgray;margin-bottom: 10px;">
<tr style="text-align: center;"><td style="border-right: 1px solid gray;">Teacher</td><td style="border-right: 1px solid gray;">Medium</td><td>Lessions</td></tr>
<tr style="text-align: center;"><td style="border-right: 1px solid gray;"><a href="" style="color:black">'. $row['Teacher Name'] . '</a></td><td style="border-right: 1px solid gray;"><a href="" style="color:black">'. $row['Medium of Teaching'] . '</a></td><td>'. crud::getRecordCountConditional('tbl_lession','lessionID','courseID',$row['Course ID']) . '</td></tr>
</table>
<hr>
<p style="text-align: center;font-size: 20px;">Price:₹<del style="font-size: 20px;">' . number_format($row['Original Price']) . '</del> <span style="color: red;font-weight:bolder;font-size: 20px;">' . $row['Disco Price'] . '/-</span></p>
<hr>
<p class="card-text"><a href="courseDetails.php?courseID_Qry='. base64_encode($row['Course ID']) .'" class="btn " style=" background-color: royalblue;width:100%;"> View Details</a></p>
<p class="card-text"><a href="courseDetails.php?courseID_Qry='. base64_encode($row['Course ID']) .'" class="btn btn-success" style="width:100%;"> Buy Now</a></p>
</div>
</div>';
}
}
else
{
$filteredCourses = '<h3 style="margin-top: 5%;">No Such course Found....</h3>';
}
echo $filteredCourses;
}
?>