Jump to content

UndeadCircus

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by UndeadCircus

  1. HA! Wow.. I can't believe it was something that stupid. I was sitting on the couch with my fiance and staring at my code when it clicked in my head. Just as I was about to get back here and respond, I noticed your post. Thanks a lot for replying.
  2. Hey everyone, Got an interesting problem here that's driving me nuts. What I'm trying to do is store an array in a session variable. I'm trying to do this with a for loop. This is what I have right now: session_start(); $frmTourDates = 1500; for($i=0;$i<5;$i++){ $_SESSION['tourDates'] = array(); $_SESSION['tourDates'][$i] = $frmTourDates; $frmTourDates += 500; } print_r($_SESSION['tourDates']); But for some reason, this is only giving me one value in the array with I use the print_r command. The output is: Array ( [4] => 3500 ) Is there some reason it won't give me [0] => 1500, [1] => 2000, [2] => 2500, [3] => 3000, [4] => 3500? I would think that using $i inside of $_SESSION['tourDates'][$i] would pretty much say $_SESSION['tourDates'][0], $_SESSION['tourDates'][1], $_SESSION['tourDates'][2], $_SESSION['tourDates'][3], $_SESSION['tourDates'][4] since the $i variable is increasing by one each time. I'm racking my brain with this... Hopefully someone can help! Thanks!
  3. Hey everyone, I have another question that I'm sure is quite easy for someone else to figure out, but I'm having quite a bit of difficulty in getting a working solution. Here's what's going on... I have two tables, one is for members and the other is for items owned by each member. The member's table, dumbed down, looks something like this: Table: members member_id member_owner member_item The other table for the item, looks something like this: Table: items item_id item_value What I have going on is that each person who signs up to the website (this is a browser-based MMORPG) is in control of anywhere between 2-5 people. These are all held in the "members" table (different from the users table, where the 'member_owner' field would actually be the ID of the user that controls that character). Each of the people that the user controls has their own special item, which the "member_item" value points to the item_id value in the items table. What's needing to happen is when the user goes into "Practice" on the website, the script will take the item_value of ALL of the items the member's are equipped with (so say member 1 is equipped with item_id 1 with item_value of 0.02, member 2 is equipped with item_id 2 with item_value of 0.03 and member 3 is equipped with item_id 3 with item_value 0.04). Those three item_values need to be totaled together and that is the strength of the entire group, 0.09. This is always a dynamic value since each user can control a maximum of 5 people and a minimum of 2. Do you guys think this should be in a while loop? I've though about using the SUM function in MySQL, but I don't see how it can return ALL of the item_value fields for each member. I hope that wasn't too confusing and was in-depth enough to understand. I appreciate any and all help! Thanks guys!
  4. That's pretty much how it goes. PHP isn't meant to be stand-alone. You gotta have a backing language to go with it.
  5. This isn't really math related.. But if you're talking about the hex values for colors, this website can help: http://ficml.org/jemimap/style/color/wheel.html
  6. Yea, after I plopped the code in and tweaked it a little, I started to study it to find out exactly what's going on.. And it makes me feel kind of senseless knowing that it was so easy. But then again, being exausted and completely braindead from staring at code all day will have impacts on your brain that push out even the most remedial of tasks, haha. But again I say - thanks a ton. I can sleep soundly tonight knowing one of the biggest aspects of this game are now complete haha.
  7. Thanks a MILLION to you guys! I actually ended up going with Daniel0's answer, I just had to add an extra "*100" to the end of the equation and it balanced everything out. Holy crap.. All day I've been working on this and it comes down to a very simply formula. Words can't describe how thankful I am to you guys right now, lmao. @ignace: Yea, about the database levels.. I knew it could cause some issues like that down the road, but it was the most practical way I could think of in dealing with user's levels later down the road when it comes to the way the game is handling leveling up, etc. But I appreciate the feedback nonetheless. I'll definitely keep what you said in mind! Thanks again guys.. Major props to you for the help.
  8. Man.. I was really hoping that would work because it seemed like such an easy answer.. But still, no such luck. I appreciate your reply though! Maybe you have another idea?
  9. Hey everyone, I'm new to the forums, but not quite new to PHP...Except it feels like I'm a COMPLETE n00b. I have quite an interesting problem here.. I'll try to explain it in as much depth as I can without it being too confusing. I'm developing an online game and I'm trying to get a progress bar that updates based on what a user's experience points are. I have a table called "levels" setup which is setup so that auto-increment "id" column is the actual level the user can obtain. In this table, I have levels_minfans and levels_maxfans. The rows inserted into this table look something like this: levels_id: 1 levels_minfans: 0 levels_maxfans: 74 levels_id: 2 levels_minfans: 75 levels_maxfans: 149 levels_id: 3 levels_minfans: 150 levels_maxfans: 299 Now, what happens is if the user has anywhere between 0 and 74 fans, he is at level 1. When they hit 75 fans up to 149 fans, they are level 2 and so on. Well, I'm trying to get my static progress bar to display the percentage between these two values. Such as if they are level three, I need it so that the progress bar is at zero when they have 150 fans, and increment up to 100 as they hit 299 fans. So, in short, 150 fans really equals zero percent, and 299 fans equals 100 percent. I think that might be in depth enough to understand the problem. I've been dealing with this crap ALL day today and no matter what combination of math formulas I try, I can't seem to get the progress bar to reset at zero everytime a new level is hit and the player has the minimum number of fans for that level and then top out at 100 when they reach the max fans for that level. Does all of this make sense? If so, I'd appreciate any help I can get from you guys. Thank you so much for reading this - hope I can get an answer soon! Ricky
×
×
  • 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.