require_once('includes/sidebar.php'); ?>
$sql = '
SELECT cr.*, crc.cat_name AS subcategory, crmc.cat_name AS category,
(
SELECT COUNT(*) FROM orders AS o
WHERE o.car_id = cr.id
) AS totalBookings
FROM carrental AS cr
LEFT JOIN carrentalcat AS crc ON crc.id = cr.cat_id
LEFT JOIN carrental_main_cat AS crmc ON crmc.id = cr.main_cat_id
WHERE 1 = 1
';
if(isset($main_cat_id) && $main_cat_id > 0){
$sql .= 'AND cr.main_cat_id LIKE "%,'.$main_cat_id.',%" ';
}
if(isset($_REQUEST['keyword']) && $_REQUEST['keyword'] != ''){
$sql .= 'AND cr.car_name LIKE "%'.mysqli_real_escape_string($con, trim($_REQUEST['keyword'])).'%" ';
}
$sql .= 'ORDER BY cr.sOrder ASC ';
$totalRows = mysqli_num_rows(mysqli_query($con, $sql));
$limit = 12;
if(isset($_REQUEST['pageNo']) && $_REQUEST['pageNo'] > 0){
$offset = ($_REQUEST['pageNo'] - 1);
}else {
$offset = 0;
}
if(!isset($_REQUEST['viewall'])){
$sql .= ' LIMIT '.$limit.' OFFSET '.($offset*$limit);
}
#echo $sql;
$res = mysqli_query($con, $sql);
?>
if($res && mysqli_num_rows($res) > 0): ?>
while($row = mysqli_fetch_object($res)): ?>
$id = $row->id;
$car_name = stripslashes($row->car_name);
$img_title = stripslashes($row->img_title);
$description= strip_tags(stripslashes($row->description), '
'); if(strpos($row->img, '/images') !== false){ $imgPath = '.'.stripslashes($row->img); }else { $imgPath = './images/cars/'.stripslashes($row->img); } $carUrl = makePermaLink($car_name).'-'.$id.'.php'; $reserveCarUrl = 'reserve-'.makePermaLink($car_name).'-'.$id.'.php'; if($row->available == 1){ $linkText = 'Get a quote'; }else { $linkText = 'Not Available'; } ?> endwhile; ?> else: ?> No Vehicle(s) Found! endif; ?>
'); if(strpos($row->img, '/images') !== false){ $imgPath = '.'.stripslashes($row->img); }else { $imgPath = './images/cars/'.stripslashes($row->img); } $carUrl = makePermaLink($car_name).'-'.$id.'.php'; $reserveCarUrl = 'reserve-'.makePermaLink($car_name).'-'.$id.'.php'; if($row->available == 1){ $linkText = 'Get a quote'; }else { $linkText = 'Not Available'; } ?> endwhile; ?> else: ?> No Vehicle(s) Found! endif; ?>