Jump to content

sandrob57

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Everything posted by sandrob57

  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
  15. Ok I came up with this (it doesnt work, but I feel it's a step in the right direction) $result = dbquery("SELECT DISTINCT ip,SUM(ip) AS ip_count FROM fusion_ip LIMIT $rowstart,20 ORDER BY ip_count, DESC"); edit: still cant get it to work ???
  16. ok this is my current query. Not a good start, because there is already a syntax error, but it should give you an idea of what I want to do: $result = dbquery("SELECT DISTINCT ip FROM fusion_ip LIMIT $rowstart,20"); Basicaly my website records every ip a user has logged on from and keeps it saved in a table called fusion_ip. The columns for the table are ip_id (a auto increment id assigned to each ip), ip (the ip) and user_id (the id of the user the ip belongs to). As an example, the db may look like this ip_id__user_id___ip 1_____33______111.212.32.32 2_____1_______111.212.32.32 3_____1_______43.12.1.3 4_____5_______67.86.54.2 5_____2_______72.65.5.4 What I am trying to do is make a list of every IP and sort them by the most active. So the list would look like this: [____IP____][_Users Using This Ip__] 43.432.424.2________4 5.4.32.1____________2 etc. etc. So how the hell would I make a query capable of accomplishing this? EDIT: im guessing a i need a SUM() somewhere in there, or an order by?
  17. I want to reduce the amount of queries if possible, or make this more efficient. I'm just asking if there is a better way of writing this.
  18. Anyway to simplify/reduce the amount of queries I use here (they will get loaded on every page by hundreds of users simultaneously)? It's an IP system Im building to record the IP's of my users. If working correctly, it should add a new entry each time their IP changes, and keep up to 10 records of IP changes. //This basicaly checks if you have an row AT ALL in the ip history table. If not, it creates one $result = dbquery("SELECT user_id FROM fusion_ip WHERE user_id='".$userdata['user_id']."' ORDER BY date DESC LIMIT 1"); while ($data = dbarray($result)) { if ($data['user_ip'] != $_SERVER['REMOTE_ADDR']) { //Inserts your IP data dbquery("INSERT INTO fusion_ip (user_id, ip, date) VALUES ('".$userdata['user_id']."','".$_SERVER['REMOTE_ADDR']."','".time()."')"); } } if ($result != $userdata['user_id']){ //This adds a new peice into your history $result = dbquery("INSERT INTO fusion_ip (user_id, ip, date) VALUES ('".$userdata['user_id']."','".$_SERVER['REMOTE_ADDR']."','".time()."')"); //This deletes your ip history if you have over 10 stored in DB $result = dbquery("SELECT ip_id FROM fusion_ip WHERE user_id='".$userdata['user_id']."'"); $total = 0; $delete_amount = 0; while ($data = dbarray($result)) { $total =+1; } if ($total > 10) { $delete_amount = $total - 10; $result = dbquery("SELECT user_id FROM fusion_ip WHERE user_id='".$userdata['user_id']."' ORDER BY date ASC LIMIT ".$delete_amount.""); while ($data = dbarray($result)) { $result = dbquery("DELETE FROM fusion_ip WHERE ip_id='".$data['ip_id']."'"); } } }
  19. i love how the answers are always so damn simple this is what not programming for a month does to you thanks, though
  20. My current query: $result = dbquery("SELECT user_id FROM fusion_ip WHERE user_id='".$userdata['user_id']."'"); I want the query to select the row with the highest number (or, in this case, datestamp). So if this were the database ___ip_id____ ___user_id___ ____ip____ ____date____ 1 1 7.777.77.7123413243 2 1 5.555.55.5343434343 3 1 7.777.77.7543245234 The query would select row 3 because the date is the most recent
  21. What causes the roll over effects like the ones found on this page (put your mouse over an item http://armory.worldofwarcraft.com/character-sheet.xml?r=Smolderthorn&n=Selkies ) Is it java script? If so, what is the effect called? Could I get a link to some tutorials? Thanks. (I know this isn't a 100% php question, but I dont even know where to start asking for this question >.>)
  22. Wow. How did I miss that one. *smacks head* Ok it works now, thanks.
  23. the function is the entire file of !get_minerals.php The page I am having problem with: <?php include "!get_minerals.php"; get_minerals($userdata['user_id']); print_r ($userminerals); $userdata['user_id'] == 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.