From 7b1e018004f13bb39c83f927bb31279ecd208452 Mon Sep 17 00:00:00 2001 From: Rubenwardy Date: Sat, 25 Aug 2012 11:32:23 +0100 Subject: [PATCH] Made the number of mods in index.php dynamic Number is no longer preset, and is change by a query --- index.php | 36 +++++++++++++++++++----------------- scripts/setup.php | 6 ++++++ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/index.php b/index.php index c1bfa82..1dd11a3 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,10 @@ $title$description$num"; + function listSearch($query,$title,$description,$handle){ + echo "$title$description"; + $num=getNoTopics($query,$handle); + echo "$num"; } function seperator($cols){ @@ -14,27 +16,27 @@ echo ""; //List Categories - listSearch("","All","All Items",2); - listSearch("mod","All Mods","All Mods",2); - listSearch("modpack","All Mod Packs","All Mod Packs",0); - listSearch("texture","All Texture Packs","All Texture Packs",0); + listSearch("","All","All Items",$handle); + listSearch("mod","All Mods","All Mods",$handle); + listSearch("modpack","All Mod Packs","All Mod Packs",$handle); + listSearch("texture","All Texture Packs","All Texture Packs",$handle); seperator(4); - listSearch("deco","Block Adder Mods","Adds basic decorating blocks to the game (eg: moreblocks, homedecor)",0); - listSearch("fun","Fun Mods","Fun mods for the game (eg: Chess, Mesecons)",0); - listSearch("server","Server Interaction Mods","Mods ideal for servers (eg: antigrief, money)",0); - listSearch("mobs","Mob Mods","Mods that add Mobs",0); - listSearch("3d","3D Object Mods","Mods that use NodeBoxes",1); + listSearch("deco","Block Adder Mods","Adds basic decorating blocks to the game (eg: moreblocks, homedecor)",$handle); + listSearch("fun","Fun Mods","Fun mods for the game (eg: Chess, Mesecons)",$handle); + listSearch("server","Server Interaction Mods","Mods ideal for servers (eg: antigrief, money)",$handle); + listSearch("mobs","Mob Mods","Mods that add Mobs",$handle); + listSearch("3d","3D Object Mods","Mods that use NodeBoxes",$handle); seperator(4); - listSearch("comic-txt","Comic Style","Cartoon Style Texture Packs",0); - listSearch("real-txt","Realistic","Realistic Styled Texture Packs",0); - listSearch("hd-txt","HD","HD Texture packs",0); + listSearch("comic-txt","Comic Style","Cartoon Style Texture Packs",$handle); + listSearch("real-txt","Realistic","Realistic Styled Texture Packs",$handle); + listSearch("hd-txt","HD","HD Texture packs",$handle); seperator(4); - listSearch("0.4.2","0.4.2","for 0.4.2-rc1",2); - listSearch("0.4.1","0.4.1","for 0.4 Stable",2); - listSearch("0.4","0.4","for 0.4",1); + listSearch("0.4.2","0.4.2","for 0.4.2-rc1",$handle); + listSearch("0.4.1","0.4.1","for 0.4 Stable",$handle); + listSearch("0.4","0.4","for 0.4",$handle); //listSearch("0.3","0.3","for 0.3",0); //listSearch("old_minetest","Older","for older versions of minetest",0); diff --git a/scripts/setup.php b/scripts/setup.php index 0d36a16..d57c59f 100644 --- a/scripts/setup.php +++ b/scripts/setup.php @@ -69,4 +69,10 @@ function require_login(){ header("location: login.php?redir=".curPageURL()); } } + +function getNoTopics($tag,$handle){ + $qu = mysql_real_escape_string ($tag); + $res = mysql_query("SELECT * FROM mods WHERE tags LIKE '%$qu%' ORDER BY likes DESC",$handle); + return mysql_num_rows($res); +} ?> \ No newline at end of file
CategoryDescriptionMods