function standardlisting($cat) { global $conn; $rows = 10; if ($cat === "N/A") { $sql = "SELECT COUNT(*) FROM listing WHERE bool_approved = 1"; } else { $sql = "SELECT COUNT(*) FROM listing WHERE int_category = ? AND bool_approved = 1"; } $stm = $conn->prepare($sql); $stm->execute(array($cat)); $count = $stm->fetchColumn(); $totalpages = ceil($count / $rows); if (isset($_GET['page'])) { $currentpage = $_GET['page']; } else { $currentpage = 1; } $offset = ($currentpage - 1) * $rows; if ($cat === "N/A") { $sqlListings = "SELECT * FROM listing WHERE bool_approved = 1 ORDER BY dt_date_listed DESC LIMIT {$offset}, {$rows}"; } else { $sqlListings = "SELECT * FROM listing WHERE int_category = ? AND bool_approved = 1 ORDER BY dt_date_listed DESC LIMIT {$offset}, {$rows}"; } $stm = $conn->prepare($sqlListings); $stm->execute(array(category())); $listing = $stm->fetchAll(); if ($listing) { $loop = "<ul class='listing'>"; foreach ($listing as $row) { $loop .= "<a target='_blank' title='Visit " . $row['nm_site_name'] . "' href='http://" . $row['url_site_address'] . "'><h3>" . $row['nm_site_name'] . " <i class='icon-fixed-width icon-globe'></i></h3></a>"; $loop .= "</a><p>" . $row['tx_site_description'] . "...</p>" . generatelink($row['int_category'], $row['id_site']) . "<p align='right'>Read More...</p><hr>"; } $loop .= "</ul>"; } else { $loop = "There are currently no listings in this category"; } echo $loop; pagination($currentpage, $totalpages, $cat); }
function recent_listings($category) { global $conn; if ($category == 0) { $sql = "SELECT * FROM listing ORDER BY dt_date_listed DESC LIMIT 10"; } else { $sql = $sql = "SELECT * FROM listing WHERE int_category = :category ORDER BY dt_date_listed DESC LIMIT 10"; } $stm = $conn->prepare($sql); $stm->execute(array(":category" => $category)); $listings = $stm->fetchAll(); $loop = "<ul class='well'>"; if (!empty($listings)) { foreach ($listings as $row) { $loop .= "<center><a target='_blank' title='Visit " . $row['nm_site_name'] . "' href='http://" . $row['url_site_address'] . "'><h5>" . $row['nm_site_name'] . " <i class='icon-fixed-width globe icon-globe'></i></h5></a>"; $loop .= generateicons($row['bool_featured'], $row['bool_premium']); $loop .= "<img src='../" . $row['tx_site_image'] . "' class='img-responsive' /></center></a>"; $loop .= "<p>" . $row['tx_site_description'] . "</p><br><br>"; $loop .= "<p><a class='btn btn-success view-listing' style='text-align:center; width:100%;' target='_blank' href='../" . generatelink($row['int_category'], $row['id_site']) . "'>View listing</a></p>"; $loop .= "<p><a class='btn btn-danger view-listing' style='text-align:center; width:100%;' onclick='return makesure();' href='?cat=" . $category . "&declineid=" . $row['id_site'] . "'>Remove Listing</a></p>"; $loop .= "<div class='clearfix'></div><hr>"; } } else { $loop .= 'No listings found'; } $loop .= "</ul>"; echo $loop; }