Jump to content

Kasuke_Akira

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by Kasuke_Akira

  1. I was curious if someone had an example of how to pull the first value out of an array ($array[0]) and compare it to every following value in the array ($array[1],[2],etc....) Then compare the next value ($array[1]) and compare it to every following value ($array[2],[3],etc....). The goal is to find any matches and, if so, to report that match. I'm having trouble how to figure it out. Someone recommended a combination of foreach() and array_search() but I didn't get it.
  2. I have a big huge question here. I've been having trouble how to get everything to work together. I have two textareas: main, side I need to take the information from main and side which will always look like this in its general format: 4 Shock 3 Disenchant etc.... I need to check main and side (independantly within their ownselves) for any duplicate entries such as: 4 Shock 2 Shock Then I need to compare main and side to be sure if there are duplicate entries, they dont add up to more than 4. The thing with all this is, each textarea is being arrayed by using: $main_split = explode("\n", $main); which results in: $main_split[0] = "4Shock" then each set pulled out is being furthered arrayed as such: $main_card_split = explode("\n", $main_split[$i], 3); which results in: $main_card_split[0] = "4" | $main_card_split[1] = "Shock" I'm using while statements to achieve this already. I just need to be able to take the words and compare within each textbox to make sure there are no duplicates, then compare the main and side to check that if there are duplicates, their corresponding numeric values only add up to 4.
  3. Ahh..ok..didnt know about GROUP BY..i need to read a mySQL book...lol
  4. if you order by fieldname..it rearranges the table by field name, grouping all the same together before it is processed. then it would cycle through each enrty, it only grabs the num rows in the DB WHERE $field_name = $temp, after it decides if that $temp != $data[fieldname]. when it does come across one that doesnt equal it, it assigns $temp the new value, searches the table for all the rows with field_name = $temp, counts them up, displays and continues to run through each row, till it finds a nother that isnt equal it should work cuz i use the same concept to group names based on a certain type in another website i have. if you order by, it orders the whole table in that order grouping ebay, yahoo, etc together... Besides, I don't see syntax errors. and it IS ordered by field_name (you jsut replace 'field_name' with the appropriate fieldname.............the same with any instance of 'table' the only reason it wouldnt work is if i typed something wrong. but the concept is right as long as everything is typed right.
  5. Wow, that would make things eaasier. all u have to do is store one format and u can convert it to any you need.
  6. mebbe you overwrote a file with some common name so now only one of the file's information is there?
  7. $result = mysql_db_query(SELECT * FROM table ORDER BY field_name); $temp = ""; while ($data = mysql_fetch_array($result)) { if ($temp != $data[field_name]) { $temp = $data[field_name]; $num_rows = mysql_num_rows(SELECT * FROM table WHERE field_name = '$temp'); echo "$temp = $num_rows<br />"; } } That should work..if not tell me errors and I'll figure it out. I'm at work and have no way to look at my scripts to see if it's right.
  8. Ahh, thanks. lol...i was using commas instead of | so i knew it wasnt working..just didnt know wut it should be. thanks
  9. Here's what an example set of arrays looks like. There are over 100 search strings with corresponding replacement strings: $search_str[0] = '/Time Spiral Common/'; $search_str[1] = '/Time Spiral Unommon/'; $search_str[2] = '/Time Spiral Rare/'; $search_str[3] = '/Stronghold Common/'; $search_str[4] = '/Stronghold Unommon/'; $search_str[5] = '/Stronghold Rare/'; $replace_str[0] = '<img src\'images/tsp c.gif\'>'; $replace_str[1] = '<img src\'images/tsp u.gif\'>'; $replace_str[2] = '<img src\'images/tsp r.gif\'>'; $replace_str[2] = '<img src\'images/sth.gif\'>'; $replace_str[3] = '<img src\'images/sth.gif\'>'; $replace_str[4] = '<img src\'images/sth.gif\'>'; If you notice for the images for TS, they vary based on Rare, Uncommon, or Common However, there are no different images for each rarity of Stronghold, the same image has to be used. but I don't want to have to define 3 different search and image arrays, for the same image. I know you can do stuff like this : [0-9] and it will search for anything between 0 and 9 instead of having to do a separate instance in the array for each number. but I need the same thing to be done with common uncommon and rare so that Stronghold is constant, but one of those other three can be true as well: $search_str[3] = '/Stronghold [Common,Uncommon,Rare]/'; I know that isn't how it works, but I think you may understand what I mean now.
  10. Hmm..lets try a different approach..lol I want any instances of Stronghold Common, Stronghold Uncommon, Stronghold Rare to be replaced with: $replace_str[0] = '<img src\'images/sth.gif\'>'; But I don't want to have to do this: $search_str[0] = '/Stronghold Common/'; $search_str[1] = '/Stronghold Unommon/'; $search_str[2] = '/Stronghold Rare/'; $replace_str[0] = '<img src\'images/sth.gif\'>'; $replace_str[1] = '<img src\'images/sth.gif\'>'; $replace_str[2] = '<img src\'images/sth.gif\'>'; I want to do this: $search_str[0] = '/Stronghold [different options]/'; $replace_str[0] = '<img src\'images/sth.gif\'>';
  11. I have three options: Stronghold Common Stronghold Uncommon Stronghold Rare I want preg_replace() to search for all three, and replace with the same array so that I don't have to make three seperate array options for each entry but I'm not sure what the search string would look like.
  12. How would i grab the first value [0] in an array, check to see if any value after it[1][..] is the same, and then move to the next one[1], checking if to see if any value after that one [2][..] is the same?
  13. I have this variable: $str = "4xAura Extraction"; I need it to split the string into two separate strings containing this: $split[0]: 4 $split[1]: Aura Extraction I can't use explode(), because that will split it up again if there are x's other than the one that comes after the number. What would be the best way to get this done. I'm asking because I'm not real good at string manipulation when it comes to mutilating them. lol Thanks
  14. Basically what I just said and yes, a lengthy process because you will need to identify EVERYTHING pertinent to making a post in phpBB or it won't work properly.
  15. Does it matter the purpose? Now I could understand you wanting more details of the process, but does his reason matter if you know how? And to asnwer his question, it has theoretical possibilities. All you need to do is find all the relevant PHP code for posting into a forum. Basically, where it needs to be placed in the database, make sure all your variables are named appropriately when passing through pages, and what your SQL query would be when inputting it. I know many sites integrate the login system of phpBB with that of their own site so that you only have to login once. So as long as you can decipher the code, you can figure out how to incorporate the two.
  16. Say I have a user input a search string and they click search. What would my mySQL string look like if i wanted it to search TABLE:'set_01' and TABLE:'set_02' at the same time for the same information?
  17. OK, well I switched it from using my arrays, to setting it up like your example instead. So that will do for now. Thanks. I'll just fiddle with my own code later....mebbe i can figure out wut I'm doing wrong.
  18. In time, it would of course slow down. However, imo, (though I'm not some databse structure guru) your structure looks decent enough. The more you can spread the information into other tables, the better off you are going to be with load times if you are only accessing certain tables at a time and not all of them.
  19. Have your php script add directories and create the new .txt file in that user's directory. Seems the most logical as there is no way to stop a file from overwriting one with the same name in the same directory.
  20. Here's my code: function cmc_convert ($str) { $simple_search = array( '16', '12', '11', '10', '9', '8', '7', '6', '5', '4', '3', '2', '1', 'W', 'U', 'B', 'R', 'G' ); $simple_replace = array( '<img src=images/cmc_16.png>', '<img src=images/cmc_12.png>', '<img src=images/cmc_11.png>', '<img src=images/cmc_10.png>', '<img src=images/cmc_9.png>', '<img src=images/cmc_8.png>', '<img src=images/cmc_7.png>', '<img src=images/cmc_6.png>', '<img src=images/cmc_5.png>', '<img src=images/cmc_4.png>', '<img src=images/cmc_3.png>', '<img src=images/cmc_2.png>', '<img src=images/cmc_1.png>', '<img src=images/cmc_white.png>', '<img src=images/cmc_blue.png>', '<img src=images/cmc_black.png>', '<img src=images/cmc_red.png>', '<img src=images/cmc_green.png>' ); $str = preg_replace($simple_search, $simple_replace, $str); return $str; } Basically....I don't know why it isn't working. I realize it's probably in the $simple_search array, but I am not too good at string manipulation and was curious what I'm doing wrong. If you know what I'm doing wrong and how to fix it, if you do fix it, can you explain to me why? So I understand what's going on. Thanks.
  21. Thanks Wasn't sure if I was gonna get a response.
  22. preg_replace() works like this: $output = preg_replace($search_for, $replace_with, $in_this_string);
×
×
  • 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.