"Bricks", 1=>"Robots", 2=>"Chassis", 3=>"Furniture", 4=>"Roads", 5=>"Billboards", 6=>"Game Objects", "MyDecals"=>"My Decals", "FreeDecals"=>"Free Decals", "MyModels"=>"My Models", "FreeModels"=>"Free Models" ]; $category = isset($_POST['category']) && isset($categories[$_POST['category']]) ? $_POST['category'] : "FreeModels"; $categoryText = $categories[$category]; $type = strpos($category, "Decals") ? 13 : 10; $page = $_POST['page'] ?? 1; $keywd = $_POST['keyword'] ?? false; if(is_numeric($category)) //static category { //$query = $pdo->prepare("SELECT COUNT(*) FROM catalog_items WHERE toolboxCategory = :category"); //$query->bindParam(":category", $categoryText, \PDO::PARAM_STR); } else //dynamic category - user assets, catalog assets { if(SESSION && strpos($categoryText, "My") !== false) //get assets from inventory { $assetCount = Database::singleton()->run( "SELECT COUNT(*) FROM assets WHERE type = :type AND approved = 1 AND id IN (SELECT assetId FROM ownedAssets WHERE userId = :uid)", [":uid" => SESSION["user"]["id"], ":type" => $type] )->fetchColumn(); } else //get assets from catalog { $assetCount = Database::singleton()->run( "SELECT COUNT(*) FROM assets WHERE type = :type AND approved = 1 AND (name LIKE :q OR description LIKE :q)", [":type" => $type, ":q" => "%{$keywd}%"] )->fetchColumn(); } } $pagination = Pagination($page, $assetCount, 20); if(is_numeric($category)) //static category { //$query = $pdo->prepare("SELECT * FROM catalog_items WHERE toolboxCategory = :category ORDER BY id ASC LIMIT 20 OFFSET :offset"); //$query->bindParam(":category", $categoryText, \PDO::PARAM_STR); } else //dynamic category - user assets, catalog assets { if(strpos($categoryText, "My") !== false) //get assets from inventory { $assets = Database::singleton()->run( "SELECT assets.* FROM ownedAssets INNER JOIN assets ON assets.id = assetId WHERE userId = :uid AND assets.type = :type ORDER BY timestamp DESC LIMIT 20 OFFSET :offset", [":uid" => SESSION["user"]["id"], ":type" => $type, ":offset" => $pagination->Offset] ); } else //get assets from catalog { $assets = Database::singleton()->run( "SELECT * FROM assets WHERE type = :type AND approved = 1 AND (name LIKE :q OR description LIKE :q) ORDER BY updated DESC LIMIT 20 OFFSET :offset", [":type" => $type, ":q" => "%{$keywd}%", ":offset" => $pagination->Offset] ); } } ?>
Pages>1) { ?>
fetch(\PDO::FETCH_OBJ)) { $name = Polygon::FilterText($row->name); ?> <?=$name?>
Pages>1) { ?>