Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About natturefrk

  • Rank
  1. sorry for late reply i just got off work about an hour ago, so I was trying to see if I see why its doing this but I get a sql error say that the user_id column doesn't exist when in fact it does. The only edit I made to the code was deleting the create table code as i just did it manually because for some reason I was getting a sql error on that one too, but I checked and everything was fine.
  2. I believe they are linefeeds because <?php $highscores = explode("\n", $highscores); //here is a example of what it exactly produces: /*Array( [0] => "name, rank, level, xp" [1] => "natturefrk" [2] => "12345(number for rank), 100(number for level), 1234567(number of rank) etc .... for 27 skills*/ ?> so am i right in my assumption or am I off
  3. irrelevant side note but wanted to point it out.. now I understand you point on database design, I am stupid uggh. Maybe I need to go back to the basics and learn proper database design apparently, not being snarky to you but to myself, because my approach was always to echo the name in each table. Actually I just learned about foreign keys, which I actually knew about but never knew what it was called or why you would use? I really really really thank you for pointing that for me. I also wanted to apologize for thinking generalizing the data from $highscores would help you understand how the data is being outputted and thinking it was a good idea instead of actually providing an actual example. I also wanted to thank you for you patience. I also learned the value of doing your own research as it helped me avoid asking a question on here in the past.
  4. This is the raw data before any other changes that comes from $highscores. Rank, level, xp. All the negative vaules are what i am using the unsets for 172102,2367,204035949 244450,95,9326803 226715,99,13062902 314759,91,6351956 136596,99,24777093 112931,99,18388160 239587,94,8152884 57077,99,31947197 295686,85,3556200 269974,89,5121646 290728,85,3285716 238074,87,4161271 363824,80,2052681 169699,90,5581814 225138,85,3511420 241013,83,2701620 206930,94,8228281 162026,86,3972264 251269,73,1059054 147798,99,13294540 244330,73,1089646 166327,85,3457238 178831,82,2666078 208122,80,2176205 163361,96,10535979 215228,85,3479524 162388,84,3214554 138413,70,8883223 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 167565,4200 158618,1 -1,-1 233517,1 -1,-1 -1,-1
  5. . Yeah oddly enuff it dont so thats what I am doing with $fields to add those labels for the values.Which by the way you asked that, needs to include the labels for the skill values as well, am I right?
  6. Example output of highscores is as follows 123456(rank compared to all other players), 58(level of the skill), 1234567(total xp in skill), and just keeps repeating for all 27 skills. Ill have to look into what you suggested... not sure what you mean but pretty sure something that google search can fix.
  7. 0 What is the best way to store this data coming from the api into a csv file to later put into the db. Output: rank, level, xp, rank, level, xp, etc. This api produces about 60 rows of data per name ran and x that by about roughly 300 names that equals a lot of data. Pretty much with my current code I am pretty much creating a endless loop almost that would take a long time to execute so updating said data would be a nightmare i would think. Is there a way to accomplish the same thing without the loop or I am not sure how to go about this. My current code is a mess that much I know I am gonna be told. This code works, just not efficiently. I am thinking there may be a better way to do this. $query = $conn->prepare("SELECT name FROM users LIMIT 1"); $query->execute(); while($row = $query->fetch(PDO::FETCH_ASSOC)){ $name = $row['name']; $url = 'https://secure.runescape.com/m=hiscore/index_lite.ws?player='. $name . '';//api that the csv data is coming from $highscores = file_get_contents($url); $fields = array("Name", "Rank", "Level", "Xp");//this is to add the headers // for the csv files $implode1 = implode($fields, ",");//turn into csv format, not sure this is //even needed $implode1 .= "\n";/*this is to add a line break so that the explode below will properly put it into its own element*/ //otherwise data starts joining togather $extra_data = array("$name");/*This is to add the name that the data pertains too*/ $implode2 = implode($extra_data, ",");//turn into csv format $highscores = $implode1 . $implode2 . $highscores;//join as one array $highscores = explode("\n", $highscores);//turn each csv into an element of //its own element a bunch of unsets to remove unwanted data. Omitted them to condense the code $i = 1; header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="name.csv"'); $data = $highscores; $fp = fopen('highscores/' . $name . '.csv', 'wb'); foreach ( $data as $line ) { $val = explode(",", $line); fputcsv($fp, $val); } fclose($fp); The pdo part I was gonna include but the way I have it setup now wouldn't work. I was thinking that I would use mysql's LOAD DATA INFILE to insert the csv data to database. The end goal here is to be able to search for player stats and to use said data to keep track of xp earned during a xp competition. I PRAY that i have included enough info... I would really appreciate any feedback if possible.
  8. Really?? Huh I always thought using the database for this type of thing was a bad thing which is why I shyed away from using the database in the first place haha. Now I can use the where clause . Thank you for you input!!!!!
  9. Okay I have been working on script for about a week now. In a game(runescape) there is content known as the citadel. What you do is on weekly basis you gather resources towards upkeep and upgrades(if any). Upkeep is the weekly cost to keep the plots of the citadel up and running or they will degrade. Each tier or level that upkeep cost will change. Upgrade is any thing you are upgrading or building(new plots). You must meet upkeep first before any resources are applied to any upgrades. Every week each player can only cap a certain amount of resources. Okay now that I got that outta of the way now to explain what I am trying to accomplish. There will be a form that passes the level of each plot to the script. So what I am doing is: if($citadel = '1'){ $wood_upkeep = "1500"; $stone_upkeep = "0"; $bar_upkeep = "0"; $pbar_upkeep = "0"; $cloth_upkeep = "0"; $rations_upkeep = "0"; }elseif($citadel = '2'){ $wood_upkeep = "3600"; $stone_upkeep = "0"; $bar_upkeep = "0"; $pbar_upkeep = "0"; $cloth_upkeep = "0"; $rations_upkeep = "0"; }elseif($citadel = '3'){ $wood_upkeep = "2975"; $stone_upkeep = "2550"; $bar_upkeep = "0"; $pbar_upkeep = "0"; $cloth_upkeep = "0"; $rations_upkeep = "0"; }elseif($citadel = '4'){ $wood_upkeep = "1690"; $stone_upkeep = "1500"; $bar_upkeep = "1500"; $pbar_upkeep = "0"; $cloth_upkeep = "0"; $rations_upkeep = "0"; }elseif($citadel = '5'){ $wood_upkeep = "2250"; $stone_upkeep = "2300"; $bar_upkeep = "2200"; $pbar_upkeep = "100"; $cloth_upkeep = "0"; $rations_upkeep = "0"; $cap_limit = "2000"; }elseif($citadel = '6'){ $wood_upkeep = "2470"; $stone_upkeep = "1495"; $bar_upkeep = "1690"; $pbar_upkeep = "1365"; $cloth_upkeep = "2210"; $rations_upkeep = "0"; $cap_limit = "2350"; }elseif($citadel = '7'){ $wood_upkeep = "2800"; $stone_upkeep = "400"; $bar_upkeep = "1600"; $pbar_upkeep = "2000"; $cloth_upkeep = "3000"; $rations_upkeep = "3000"; $cap_limit = "2700"; } Times that by 10 plots that is alot of code(over 500 lines). I calculated and it would come out to over 2000 lines of code just to spit out a number of "cappers" needed to achieve x upgrade/upkeep. That is to many lines to achieve one thing. What these if/elseif statements are doing is simply just assigning the cost values based on what tier(lvl) x plot is. Then I use the cost values and add em all up and divide by the weekly cap limit and that will give me the number of cappers need to achieve x upgrade + upkeep. The cost values are static and do not change. What I am asking is if there is a simpler way to achieve the same thing with less lines of code. I thought of associative arrays, but I think I will still need all those if statements. Switch statements would generate just as much code if not more.
  10. I am thinking it was the hack I was using to stop caching, because originally I was having issues with caching and css not updating. I am not having the issues, fingers crossed, now
  11. Wow I just feel stupid. I have been dealing with these problems with my css acting weirdly that I didn't even notice that I made that mistake. Here is the weirder part is that before internally I couldn't assign classes to the dynamic content now it is letting me do it
  12. Okay I have been at this for two days now trying to figure out the source of the problem. When I use firebug to inspect the elements there is no css being applied, even though the link to external stylesheet is correct. When I use chrome developer to inspect the elements it seems default styles are being applied but not the styles I set. I checked the network portion of firebug and chrome developer and the css file in question is no where to be found. So this leads me to believe that the css file is not being loaded. I don't know if this matters but the table info on this page is being dynamically generated by php. The only way that I can get the styles to apply is if I put all the css in external stylesheet internally into stats.php. Another thing I have noticed is that I cannot use classes on any of the dynamically created content and I had to use a mix between tag selectors and inline styling. The page in question is: http://www.skillersrealm.com/includes/scripts/stats.php?rsn=CrypticKaxar This is what the page is suppose to look like: https://imgur.com/a/kexYV css file: http://skillersrealm.com/includes/css/stat.css <?php $dir_sep = DIRECTORY_SEPARATOR; $back_one = '..' . $dir_sep; $back_two = '..' . $dir_sep . '..' . $dir_sep; require_once __DIR__ . $dir_sep . $back_one . 'init.php'; if(isset($_GET['rsn']) === TRUE){ $rsn = $_GET['rsn']; $query = $conn->prepare("SELECT points, xp, part_total, conduct_total, conduct_pts, help_pts, cit_pts, event_pts, talk_pts FROM users WHERE rsn = :rsn"); $query->execute(array(":rsn" => $rsn)); ?> <!-- END PHP --> <style type="text/css" media="screen"> </style> <!DOCTYPE html> <html> <head> <!-- INCLUDE GOOGLE FONT --> <link href="https://fonts.googleapis.com/css?family=Handlee" rel="stylesheet"> <link rel="stylesheet" src="../css/stat.css" type="text/css" media="screen" /> </head> <body> <div class="mask"> <div class="content"> <div class="stats_container"> <div style="float: left; padding-left: 1%;"><img src="../images/staff.png" alt="" height="750" width="200" style="float: left;" /></div> <div style="float: right; padding-right: 1%;"><img src="../images/staff2.png" alt="" height="750" width="200" /></div> <h3 style="color: rgba(50, 205, 50, 1.0);"><?php echo $rsn; ?>'s Stat Page</h3> <table class="stats" border="1"> <!-- START PHP --> <?php while($row = $query->fetch(PDO::FETCH_ASSOC)){ $grand_total = $row['points']; $xp = $row['xp']; $cit_pts = $row['cit_pts']; $event_pts = $row['event_pts']; $talk_pts = $row['talk_pts']; $conduct_pts = $row['conduct_pts']; $help_pts = $row['help_pts']; $conduct_total = $row['conduct_total']; $part_total = $row['part_total']; } //BRINGS IN THE POINTS TABLES require_once __DIR__ . $dir_sep .$back_two . 'templates' . $dir_sep . "stats_tables.php"; } ?> <!-- END PHP --> </table><br /><br /> <?php //if(logged_in() === TRUE && $admin_id ="1" || $admin_id = "2"){ //BRINGS IN THE POINT BUTTONS require_once __DIR__ . $dir_sep .$back_two . 'templates' . $dir_sep . "pts_btns.php"; //} ?> </div><!-- END OF .STATS_CONTAINER DIV --> </div><!-- END OF .CONTENT DIV --> </div><!-- END OF .MASK DIV--> </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.