Jump to content

sandrob57

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sandrob57's Achievements

Member

Member (2/5)

0

Reputation

  1. It wont, but, on the page, where it will show if you have techs or not (and do stuff depending on it) it will think you have a tech when you dont.
  2. No, but you see, it doesn't set EACH variable. If you dont have ID 8 in your database (as purchased), then it woudl leave it blank. Example: $user['tech'][6] = 1 $user['tech'][7] = 1 $user['tech'][9] = 1 8 Isn't set, so it ins't purchased. Then someone could just put "user['tech'][8]=1" in the URL and have it.
  3. ok, im going to have an array to show how many "technologies" a user has unlocked. $user['tech'] ^^ that would mean the user has no technologies $user['tech'][1] = 1 $user['tech'][2] = 1 $user['tech'][4] = 1 ^^ that would mean tech's 1,2 and 4 are unlocked How the data is stored is db for the example above is like this: [user_id][tech_id] 1 1 1 2 1 4 To set the variable $user['tech'], i just do a querry/array of all the rows in the db where there is your user_id Then I do a for_each for the database result and it will set $user['tech'][THE TECH ID] = 1 However, couldn't someone just go to "mysite.com/index.php?user['tech']['8'] = 1" and suddenly have tech 8? How do I avoid this? Can I delete an array before playing with it? Is there a smarter way to get this data?
  4. I have an array with data in this format: $data['chart'] = array (1 => 112, 2 => 223, 3 => 334, 4 => 432, 5 => 111); I need to get it into this format: $chart [ 'chart_data' ] = array ( array ( "chart", "112", "223", "334", "432", "111"); How would I go about doing that?
  5. Well, I finally found a way that works. Take a look if ur interested (thanks for the help, although I did find another way): $income = dbquery("SELECT * FROM fusion_income WHERE user_id='".$userdata['user_id']."' ORDER BY id DESC LIMIT 0,10"); while($income_data = dbarray($income)){ $data[] = unserialize($income_data['amount']); } foreach($data as $cat => $amount){ foreach($data[$cat] as $cat1 => $amount1){ $supply[$cat1][] = $amount1; } } //Income Graphs echo "<table align='center' cellpadding='0' cellspacing='1' width='1%' class='tbl-border'>"; foreach($supply as $cat => $array){ $supply[$cat] = array_reverse ($supply[$cat]); array_reverse ($supply); $max[$cat] = 120 / max($supply[$cat]) * 1.1; echo "<tr><td class='tbl2' width='1%' style='white-space: nowrap;' align='left' rowspan='2'> "; icon("".$cat.".gif", ""); echo " </td>"; foreach($supply[$cat] as $day_number => $value){ echo" <td class='tbl1' style='white-space: nowrap;' align='left' valign='bottom'> <img src='".THEME."images/pollbar.gif' height='".(($value * $max[$cat]) + 10)."' width='12' align='bottom' style='border:1px #444 solid;'> </td> "; } echo "</tr><tr>"; foreach($supply[$cat] as $day_number => $value){ echo" <td class='tbl1' style='white-space: nowrap;' align='left' valign='bottom'> <span class='small2'>".$value."</span> </td> "; } echo "</tr>"; } echo "</table>";
  6. So I have an array, technically it looks like this: $data = Array ( [0] => Array ( [gold] => 150 [food] => 23 [wood] => 27 [stone] => 11 ) [1] => Array ( [gold] => 170 [food] => 33 [wood] => 17 [stone] => 31 ) ) simpler terms: data[0] = [gold] 50 [wood] 40 [food] 30 [stone] 25 data[1] = [gold] 30 [wood] 50 [food] 20 [stone] 65 So what I am trying to do is make graphs for each unit type, so: GOLD Day 1 - 50 Day 2 - 30 Wood Day 1 - 40 Day 2 - 50 etc. The only problem is, I don't know how to set these up into a foreach() by each resource category. So how would i go about doing that? I tried this and just told it to get GOLD but it isnt working: $income = dbquery("SELECT * FROM fusion_income WHERE user_id='".$userdata['user_id']."' ORDER BY id DESC LIMIT 0,10"); while($income_data = dbarray($income)){ $data[] = unserialize($income_data['amount']); } foreach($data[]['gold'] as $cat => $amount){ echo "$cat - $amount<br />"; } The error i get is: Warning: Invalid argument supplied for foreach() in /home/galava/public_html/page/graphs.php on line 43 sigh...
  7. I looked there, but I don't see anything that tells you how to get the sum of a multi-dimension array.
  8. This is my array $income = array( 'tax' => array( 'name' => 'Citizen Taxes', 'amount' => '45', 'description' => 'in taxes from your citizens.' ), 'house' => array( 'name' => 'Housing Upkeep', 'amount' => '12', 'description' => 'in housing upkeep costs.' ) ); I need to get the total of amount. Currently I do: $total = 0; foreach ($income as $type => $array) { $total = $total + $income[$type]['amount']; } I feel this is sloppy, and I would like to figure out how to correctly use the array_sum() function. Edit: I should mention none of the tutorials I could find helped me in multi-dimension arrays.
  9. Sounds like you need a new host >.>
  10. this is my exact code (i would have edited my previous post but it wont let me) # Rewrite Mod RewriteEngine on RewriteBase / RewriteRule ^user/(.*)$ /profile.php?lookup=$1 [L]
  11. ok problem. all the images on the page dont load, and the page takes reaaaaly long to load. I think it is messing with the URL's in the images...how do I stop this?
  12. Thank you so much! This community rules!
  13. How do I turn a url like this: myfancyurl.com/user/profile.php?lookup=321 into this: myfancyurl.com/user/321 Hmm? This possible with PHP? HALP!
  14. Ahh ok that makes sense! However, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '20' at line 1
×
×
  • 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.