Tero20051 Posted May 2, 2013 Share Posted May 2, 2013 Hey everyone, thanks god i found this forum ... i have a little problem with my up-comming project and if you have a bit of time, to help me and give me some suggestions of what scripts and stuff should i use. Well if you wander, i want to make a website like this one http://www.pwdatabase.com/ where to make a menu and add some categories, like [ Items ] - [ NPC ] - [ Monsters ] - [ Quests ] these categories will also represent a folder on the website, for example website.com/items - website.com/npc and somewhere bellow i wold like to add this search option where when you tipe a word, al quests, npc items or mobs that contain this word to be displayed there. I hope you got it what i wold like to make, please take your time and try to suggest me some scripts, or anything. Thanks you a lot, ~Tero20051 Quote Link to comment Share on other sites More sharing options...
InoBB Posted May 2, 2013 Share Posted May 2, 2013 This is easily done if all your items, NPCs, etc. are stored in their own databases. Just make a search.php page, add database query to check databases for keywords given and output to page. Add a search box to pages you want it to be seen or used. example search.php: <?php $host = "HOST"; $user = "USER"; $pass = "PASS"; $db = "Database"; // Connect to database, call error if no connection. $con = new MySQLi($host, $user, $pass, $db); if (!$con) { echo "Failed to connect to database!" . mysqli_error(); } if (isset($_POST['search'])) { $key = addslashes($_POST['search']); //in case any items, npc's etc would have ' in the name. $sql = "SELECT id, item_name, item_stats FROM items WHERE item_name LIKE CONCAT('%', ?, '%')"; $query = $con->prepare($sql); $query->bind_param('s', $key); $query->bind_result($id, $iname, $istats); $query->execute(); $query->store_result(); while ($query->fetch()) { echo $id . ", " . $iname . ", " . $istats . "<br />";// nice neat html tables, divs, w/e your flavor - to display information. } $query->free_result(); $query->close(); } This is just a quick and dirty example of the search.php. There would be a lot more (such as error handling, more complex queries to request data from several tables, etc. to go along with it), but was just showing how simple it is to get the data you seek. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.