connect_error) { die("Connection failed: " . $conn->connect_error); } $gemSpecdb = "SELECT * FROM Gemstonedata WHERE `id` LIKE '".$_GET['sku']."'"; $gemresult = $conn->query($gemSpecdb); if ($gemresult->num_rows > 0) { // output data of each row while($gemSpec = $gemresult->fetch_assoc()) { $gemTitilePage = str_replace('%20',' ',ucfirst(strtolower($gemSpec["VarietyColor"])))." ".ucfirst($gemSpec["Gemtype"])." ".$gemSpec["weight"]." carat ".strtolower($gemSpec["shape"])." cut Gemstone"; if($gemSpec["description"] != ''){ $gemDescriptionPage = "Item#: ".$gemSpec["id"]." ". $gemSpec["description"]; } } } $gemVideo = "SELECT * FROM gemstonevideo WHERE `sku` LIKE '".$_GET['sku']."'"; $gemVideoResults = $conn->query($gemVideo); if ($gemVideoResults->num_rows > 0) { // output data of each row while($gemSpecVideo = $gemVideoResults->fetch_assoc()) { $gemVideoShow = $gemSpecVideo["video"]; } } $theAND = ""; $countShape = ""; if(!isset($_GET['type']) || $_GET['type'] == ""){ $countType = ""; }else{ $countType = "Gemtype LIKE '".str_replace('%20',' ',$_GET['type'])."'"; } if(!isset($_GET['color']) || $_GET['color'] == ""){ $countColor = ""; }else{ if($_GET['type'] != ""){ $theAND = "AND"; } $countColor = $theAND." VarietyColor LIKE '".str_replace('%20',' ',$_GET['color'])."'"; } if(!isset($_GET['shape']) || $_GET['shape'] == ""){ $countShape = ""; }else{ if($_GET['type'] != "" || $countColor != ""){ $theAND = "AND"; } $countShape = "$theAND shape LIKE '".$_GET['shape']."'"; } if(!isset($_GET['pictures']) || $_GET['pictures'] == ""){ $countPicturesYes = ""; }else{ $countPicturesYes = "AND image != ''"; } if(!isset($_GET['min']) || $_GET['min'] == ""){ $countMin = ""; }else{ if($countType != "" || $countColor != "" || $countPicturesYes != "" || $countShape != ""){ $theAND = "AND"; } $countMin = "$theAND totalprice >= '".$_GET['min']."'"; } if(!isset($_GET['max']) || $_GET['max'] == ""){ $countMax = ""; }else{ if($countType != "" || $countColor != "" || $countPicturesYes != "" || $countMin != "" || $countShape != ""){ $theAND = "AND"; } $countMax = "$theAND totalprice <= '".$_GET['max']."'"; } if(!isset($_GET['minct']) || $_GET['minct'] == ""){ $countMinct = ""; }else{ if($countType != "" || $countColor != "" || $countPicturesYes != "" || $countShape != "" || $countMin != "" || $countMax != ""){ $theAND = "AND"; } $countMinct = "$theAND weight >= '".$_GET['minct']."'"; } if(!isset($_GET['maxct']) || $_GET['maxct'] == ""){ $countMaxct = ""; }else{ if($countType != "" || $countColor != "" || $countPicturesYes != "" || $countMin != "" || $countShape != "" || $countMin != "" || $countMax != "" || $countMinct != ""){ $theAND = "AND"; } $countMaxct = "$theAND weight <= '".$_GET['maxct']."'"; } if($countType != "" || $countColor != "" || $countShape != "" || $countMax != "" || $countMin != "" || $countMinct != "" || $countMaxct != ""){ $whereClause = "WHERE"; }else{ $whereClause = ""; } $gemCOUNT = "SELECT COUNT(*) FROM Gemstonedata $whereClause $countType $countColor $countShape $countMin $countMax $countMinct $countMaxct $countPicturesYes"; $gemCOUNTResults = $conn->query($gemCOUNT); if ($gemCOUNTResults->num_rows > 0) { // output data of each row while($gemSpecCount = $gemCOUNTResults->fetch_assoc()) { $gemCountTotal = $gemSpecCount['COUNT(*)']; } } $gemsPerPage = 45; $conn->close(); echo ''; ?>