Jump to content

codenature

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by codenature

  1. Great thanks again. This is fun now that I have the plan. Yay!
  2. Thank you very much for that insight. I will use random monster die roll generation for the monsters, and then I will direct them to the places like cave, castle, or town. I think I will do this by making "mountain walls" like you said, made up of long lines that say when you hit one let's say the north mountain points in between x-500 and y500, so that will be my long mountain wall, then it says "you have found the north mountain wall, you can go west or east from here" Then if they go east, they will eventually hit the "zone" for the "castle" place with a narrative story. The zone to the castle will be a vertical line from points on the mountain end wall points. does that sound decent?
  3. OOPS I guess I didn't realize what you said. The random encounter is GREAT. But I still can't use that for encountering places like towns, caves, castles, etc for a story plot.
  4. i realize what you are saying. I am making a field, where I want to player to be able to roam, and when they roam to a certain x y coordinate that I put in the database where a monster exists, they have a monster encounter. so if monster is x100,y100 player hits on that coordinate fight begins, problem is there is a very small chance in the whole map of it hitting that spot. the submit direction form checks for known monster points, and monsters show up as the points are landed on Any better suggestion would be great though. please
  5. Hi, I am making a game and I want the player to use a coordinate system using North, South, East, and West form buttons to navigate the virtual X Y coordinates. The only problem is, if I want to put a monster at location x=100 y=100 The player would have to move to that particular tiny dot on the grid, so the likelihood of them coming in contact with the monster is almost nonexistent. Please, if anyone could please show me a proper way to put into a monster in the database using a coordinate system and then the php check in the form please for the monster coordinates for one example. I can repeat the rest. It seems like I would need to check for a range of points from a virtual square, but that is a lot of numbers!! Thank you.
  6. Ok thank you!. I will read it. Also, I decided to ditch the linear "story board" method, to a simpler x,y location method. It is more like the real world, and can be just as descriptive as linear narratives. But the article should be interesting. Thank you. By the way I like your signature. LOL. If you don't succeed, or while you are not succeeding, try again(). haha.
  7. Nevermind, I just drew it out, and the growth of the scenes grows to a power of 2 if 2 scenes are added to each subsequent scene. My problem is not the database, the problem is my linear design that would create an insanely large database in just a few rooms. room 1 | | 2 3 4|5|6|7 etc etc first room 2 options room 2 , 2 options, room 3, 2 options, so that makes four options. next rooms, are 8 options. next rooms are 16 options. So unless I am wrong, the problem is the linear way I am doing to story, or something else. I don't know anymore.
  8. I am having a database structure problem. If I have scene Forest->options to go to [house] [tree] [road], then each of those 3 needs more links, so that if fI have 2 keywords for new scenes for house, tree and road, that immediately turns into 6 different scenes I have to account for in the database, here is my problem. Database ID|Story|Scene| Description|Keyword1|Keyword2| (keywords=actions the user types to display a new scene) 1 Mike | Forest | You see a..| House | Road 2 Mike | House |You see.. | Chair | Hermit how to do Road??? Now I have a problem. I am able to make the new information for the House keyword, but I cannot make an entry for the Road Keyword.
  9. Great! Thank you. Also, do you know how I would have the description for each scene in the database? Like if for Forest, I had " You see a beautiful forest with the sun shining through the trees." Please. Thank you so much for the code. Also, do those aliases in your SQL run like that? like s... for "scene"?
  10. Hi, I want to make people be able to make their own choose your own adventure game for other people. I want the database to hold each "scene" that the writer makes, then let the user put in a choice. For example here is one scene with a choice. "You are in a forest. You see a castle, a house, and a road before you. Which will you choose?" Then in the text field the user submits the keyword of either "castle", "house", or "road", and it goes to the appropriate next scene. The problem is, when the game writer is typing in his adventure, I have no clue how I should make up the User interface creating the game or linking up the "scenes". It is kind of like a tree format. Like this. Forest | | House Road Castle | | | hermit fence dragon I know I want the user to type in each scene like "forest" into the text field and submit it to the database, but I have no idea how to link lets say "House" to "Forest" or "Hermit" to House text. Or how I would echo out the next appropriate scene from the Database when the user enters the name of a new scene like "House". Ideally the page would not reload when the user types a new scene, maybe ajax for that? I have no clue, Thank you in advance for any ideas.
  11. cool thank you! I just have one last question. I don't know how to create the table "matching_interests " in relation to the other tables. It seems like it is by itself and not mentioned in the code which confuses me. that is pretty much all I don't understand now. Thank you so much!
  12. with the alter table, like this? CREATE TABLE users { id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL } ENGINE=InnoDB; CREATE TABLE user_interests { id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, user_id INT UNSIGNED NOT NULL REFERENCES users(id), interest VARCHAR(255) NOT NULL } ENGINE=InnoDB; ALTER TABLE user_interests ADD INDEX (interest);
  13. Thank you. Is this correct below in long hand? Please. $sql = "SELECT users.*, GROUP_CONCAT(user_interests.interest) AS matching_interests FROM users AS users INNER JOIN user_interests AS user_interests ON user_interests.user_id = users.id WHERE user_interests.interest IN ({$interests}) GROUP BY users.id; I also still don't know where "matching_interest" is created or used ALTER TABLE user_interests ADD INDEX (interest); What is a CREATE DDL? please. sorry for my newbiness. I do understand most of it though. thank you! Also, that concatenation is interesting. I don't think I have ever seen that used in SQL. I could be wrong though.
  14. Thank you!!! Wow. thank you so much for your time again. You really know what you are doing....I am not worthy. There are some things I don't understand in your code. Here they are. $sql = "SELECT u.*, GROUP_CONCAT(ui.interest) AS matching_interests // I don't understand u.*, or ui.interest or where "matching_interest" comes from. Like where does the u and ui come from? FROM users AS u INNER JOIN user_interests AS ui ON ui.user_id = u.id WHERE ui.interest IN ({$interests}) GROUP BY u.id; ALTER TABLE user_interests ADD INDEX (interest);// I don't know where to add this in the code. do I add this to the first code you replied with? If you can help that would be great again. You are pretty advanced.
  15. Wow Smoseley, thanks very much for that code! I really appreciate your time. Do you know how I would search via a form for 3 matching interests that are in the database? Now that I put the interests in the database. I need to have a form where the user types in the desired matching interests, and results show up in order of how many matched per user in the database. I don't know if that is too complicated. I have an idea of how I would do it if there were fields like "interest 1" "interest 2" in the database, but no idea how I would do it in a relational database. Thanks again for replying, I thought no one would. your reply was awesome so thank you. (I just tried to solve it myself with googling "searching through a relational database" but I can't see any tutorials on it, just articles)
  16. Hi, Is it possible to have a user put in different hobbies in one text field , and have those words be entered into the database, into one field in the database as a searchable list? Meaning, can you have a list of words in one database field, and then run a script that compares the hobbies list with other peoples' hobbies list? Thanks in advance for any ideas.
  17. Hi, I want to make a visual php mysql based multiplayer role playing game, of the Dungeons and Dragons type, I don't know if it would be tile based or what the most advanced interface I could do would be in php. But ideally it would not have to reload the page every time, could I do that with ajax? Please if anyone can give me a link to a really good multiplayer rpg that has a very good interface where you can see the "monsters and players" moving upon user moves. Thank you.
  18. I got it to work by removing the last "}", but it says upon the page reload after submit Your Search Results Search Results for "": when I enter in a color like red. I echoed out the array, it says this: SELECT * FROM users WHERE (colors LIKE '%%') OR (shapes LIKE '%%') looks wrong to me
  19. I have completed adjusting the code, and creating the database fields. "color" and "shape". the page reloads upon the "search " button submit, and echoes out nothing, and does nothing. Please help. here is the php to process the query of the database. <?php // checks if a search has been submitted if(!empty($_POST['search'])) { // Connects to your Database mysql_connect("xxxxxxxxxxxx", "xxxxxxxxxxxxx", "xxxxxxxxx") or die(mysql_error()); mysql_select_db("ealiketwo") or die(mysql_error()) ; // the table to search $table = "users"; // explode search words into an array $arraySearch = explode(" ", $search); // table fields to search $arrayFields = array(0 => "colors", 1 => "shapes"); $countSearch = count($arraySearch); $a = 0; $b = 0; $query = "SELECT * FROM ".$table." WHERE ("; $countFields = count($arrayFields); while ($a < $countFields) { while ($b < $countSearch) { $query = $query."$arrayFields[$a] LIKE '%$arraySearch[$b]%'"; $b++; if ($b < $countSearch) { $query = $query." AND "; } } $b = 0; $a++; if ($a < $countFields) { $query = $query.") OR ("; } } $query = $query.")"; $query_result = mysql_query($query); // print title echo '<h1>Your Search Results</h1>'."\n\n"; if(mysql_num_rows($query_result) < 1) { echo '<p>No matches found for "'.$search.'"</p>'; } else { echo '<p>Search Results for "'.$search.'":</p>'."\n\n"; // output list of articles while($row = mysql_fetch_assoc($query_result)) { // output whatever you want here for each search result echo '<a href="basicSearch.php?id='.$row['id'].'">'.$row['title'].'</a><br />'; } } } else { echo "oops";// display a welcome page } } ?> and here is the form for the search. <form id="search" name="search" method="post" action=""> <input name="search" type="text" value="search" size="12" maxlength="200" /> <input type="submit" name="search" id="search" value="search" /> </form>
  20. Ok, thanks. I will try it with OR also. I may have a problem with sorting the results based on how many matches there are though.
  21. Thank you. Also, I found this code on the net. Will this do it? <?php // checks if a search has been submitted if(!empty($_REQUEST['search'])) { // the table to search $table = "yourTable"; // explode search words into an array $arraySearch = explode(" ", $search); // table fields to search $arrayFields = array(0 => "title", 1 => "content"); $countSearch = count($arraySearch); $a = 0; $b = 0; $query = "SELECT * FROM ".$table." WHERE ("; $countFields = count($arrayFields); while ($a < $countFields) { while ($b < $countSearch) { $query = $query."$arrayFields[$a] LIKE '%$arraySearch[$b]%'"; $b++; if ($b < $countSearch) { $query = $query." AND "; } } $b = 0; $a++; if ($a < $countFields) { $query = $query.") OR ("; } } $query = $query.")"; $query_result = mysql_query($query); // print title echo '<h1>Your Search Results</h1>'."\n\n"; if(mysql_num_rows($query_result) < 1) { echo '<p>No matches found for "'.$search.'"</p>'; } else { echo '<p>Search Results for "'.$search.'":</p>'."\n\n"; // output list of articles while($row = mysql_fetch_assoc($query_result)) { // output whatever you want here for each search result echo '<a href="index.php?id='.$row['id'].'">'.$row['title'].'</a><br />'; } } } else { // display a welcome page } ?>
  22. I am trying to make a form search through user input, and link it up with existing data in the database. so if in the text field, the person puts " flowers, red roses, white roses, daisies, sunflowers, cars" then they press "submit" the code then runs sql to search the database with matching terms. So that if the terms in the database field row are things->DBentry1->flowers, trucks, cars, red roses, things->DBentry2->dogs, cats, flowers it will echo out " 2 entries have matches "entry 1 has flowers, cars and red roses" "entry 2 has flowers" I want the results to be in order of number of matches returned for that database entry. it will skip "trucks because trucks was not entered and so did not match., Basically I want the search form to let the user put the terms in separated by a comma and a space or without a space, and then php and mysql find the matching terms, then echo out the results in matching order from most to least. I know that is a lot to ask of you all, but I would appreciate any help. Thanks in advance.
  23. Very nice DevilsAdvocate. Now it works great. Thank you!
  24. I have a problem with database search for a member. I am pretty sure my sql is correct. It must be my if statements. Upon submitting the search for a member, even if there is not a match, the link appears for the member that was entered into the search. I only want the link to show up if there is a match. Thank you in advance. <?php error_reporting(E_ALL); require_once("./include/membersite_config.php"); //session_start();//FOR GETTING USER ONLINE SCRIPT header("Cache-Control: nocache"); header("Expires: 0"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } $currentUser=$_SESSION['name_of_user']; // set current user name logged in to $currentUser to grab his profil DB data later. if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","100"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; include 'memberHeader.php'; if (isset($_POST['submit'])) { $memberSearch=$_POST['memberSearch']; mysql_connect(" ", " ", " ") or die(mysql_error()); // info left out mysql_select_db(" ") or die(mysql_error()) ; $sql = "SELECT username FROM users WHERE username='$memberSearch'"; $result = mysql_query($sql); echo $result; if (!$result) { echo "no matching member found " . mysql_error(); exit; } if($result) { echo "Your search result link: <a href='viewProfile.php?userPage=".$memberSearch."'>click here for result</a>"; } ////////////////////////////////MEMBER SEARCH FORM////////////// } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p> </p><p> </p><p><? echo "<p> </p><p></p><form id='form1' name='form' method='post' action=''> Enter a member's name here to search <input type='text' name='memberSearch' id='memberSearch' /> <input type='submit' name='submit' id='submit'/> </form>"; ?> </p> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.