<?php require __DIR__.'/config.php'; $pdo=db(); $q=trim($_GET['q']??'');$purpose=trim($_GET['purpose']??'');$type=trim($_GET['type']??'');$where=[];$args=[];if($q){$where[]='(title LIKE ? OR location LIKE ? OR property_id LIKE ?)';$args=["%$q%","%$q%","%$q%"];}$where2=$where;if($purpose){$where2[]='purpose=?';$args[]=$purpose;}if($type){$where2[]='type=?';$args[]=$type;}$sql='SELECT * FROM properties'.($where2?' WHERE '.implode(' AND ',$where2):'').' ORDER BY featured DESC, updated_at DESC';$s=$pdo->prepare($sql);$s->execute($args);$props=$s->fetchAll(PDO::FETCH_ASSOC);?><!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Properties | Ekemogie Global Ventures</title><link rel="stylesheet" href="style.css"></head><body><?php include 'nav.php';?><main class="container" style="padding:35px 20px"><h1>Our Properties</h1><form class="card" method="get" style="display:grid;grid-template-columns:2fr 1fr 1fr auto;gap:10px"><input name="q" placeholder="Search property, location or ID" value="<?=e($q)?>"><select name="purpose"><option value="">All purposes</option><option <?= $purpose==='For Sale'?'selected':''?>>For Sale</option><option <?= $purpose==='For Rent'?'selected':''?>>For Rent</option></select><select name="type"><option value="">All types</option><?php foreach(['House','Flat','Block of Flats','Land','Commercial','Office','Duplex','Other'] as $t):?><option <?=$type===$t?'selected':''?>><?=$t?></option><?php endforeach;?></select><button class="btn">Search</button></form><div class="property-grid"><?php foreach($props as $p):$im=$pdo->prepare('SELECT path FROM property_images WHERE property_id=? ORDER BY sort_order,id LIMIT 1');$im->execute([$p['id']]);$image=$im->fetchColumn()?:'assets/property.svg';?><article class="card"><img src="<?=e($image)?>" alt="<?=e($p['title'])?>" style="width:100%;height:230px;object-fit:cover;border-radius:10px"><h2><?=e($p['title'])?></h2><p><b><?=e($p['price'])?></b></p><p><?=e($p['location'])?></p><p><?=e($p['bedrooms'])?> bedrooms · <?=e($p['type'])?> · <?=e($p['status'])?></p><a class="btn" href="<?=e(property_url($p['property_id']))?>">View Property</a></article><?php endforeach;?></div><?php if(!$props):?><p>No properties matched your search.</p><?php endif;?></main></body></html>
