Jump to content


New Members
  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About natturefrk

  • Rank
  1. 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!!!!!
  2. 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.
  3. natturefrk

    Css not loading despite linking to it correctly

    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
  4. natturefrk

    Css not loading despite linking to it correctly

    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
  5. 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>
  6. natturefrk

    how to get php to scan all subdirectories

    I added wrong code above and can't edit it. Just realized it though. $path = 'upload/'; /* @var $file SplFileInfo */ foreach (new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path)) as $file) { if ($file->isFile() && in_array(strtolower($file->getExtension()), array('jpg', 'png', 'gif'))) { $all_paths = $file->getPathname()."<br>"; //echo '<img src="'.$all_paths.'" />'; } } When I echo $all_paths this is the output. So I am getting the paths. I tried to put $all_paths in the src attribute as you can see above but it just returns broken images. upload\Google\egret.jpg upload\Google\GraffitiCharactersTheCangolier.jpg upload\Google\hammers.png upload\Google\pictures.png upload\Google\thumbs\thumb_egret.jpg upload\Google\thumbs\thumb_GraffitiCharactersTheCangolier.jpg upload\Google\thumbs\thumb_hammers.png upload\Google\thumbs\thumb_pictures.png upload\Google\thumbs\thumb_turntable.jpg upload\Google\turntable.jpg upload\Test\aboutpage.JPG upload\Test\contactpage.JPG upload\Test\csscert.gif upload\Test\djgraffiti.jpg upload\Test\eggs.jpg upload\Test\filmstrip.jpg upload\Test\fundingpage.JPG upload\Test\homepage.JPG upload\Test\parrot.jpg upload\Test\thumbs\thumb_aboutpage.JPG upload\Test\thumbs\thumb_contactpage.JPG upload\Test\thumbs\thumb_csscert.gif upload\Test\thumbs\thumb_djgraffiti.jpg upload\Test\thumbs\thumb_eggs.jpg upload\Test\thumbs\thumb_filmstrip.jpg upload\Test\thumbs\thumb_fundingpage.JPG upload\Test\thumbs\thumb_graffitiwall2.jpg upload\Test\thumbs\thumb_homepage.JPG upload\Test\thumbs\thumb_parrot.jpg
  7. natturefrk

    how to get php to scan all subdirectories

    ok I got all the paths but how do I display the images in there own divs while limiting how much is displayed in those divs and still be able to us the more images link. I am really sorry for the noob question, but I have 0% knowledge about PHP OOP. Is there a way to do this with procedural coding? This is what I got so far $startpath = 'upload/'; $ritit = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($startpath, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST); $r = array(); foreach ($ritit as $splFileInfo) { $path = $splFileInfo->isDir() ? array($splFileInfo->getFilename() => array()) : array($splFileInfo->getFilename()); for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) { $path = array($ritit->getSubIterator($depth)->current()->getFilename() => $path); } $r = array_merge_recursive($r, $path); } echo '<pre>'; print_r($r); echo '</pre>';
  8. I have been trying to figure this out for about a week now and cannot figure it out for the life of me. I have a script that displays images from a folder and I can limit the images displayed by what ever number I choose that is what $per_row is for. It has an more images link at the bottom of the div that feeds a function the id of the group to display the rest of the images. What I am trying to figure out is how to get php to scan all the directories and have a seperate div for each directory where the more images link will still feed the right id to the function. Here is what I got so far: <?php echo '<link rel="stylesheet" type="text/css" href="../css/normalize.css" />'; echo '<link rel="stylesheet" type="text/css" href="../css/sizing.css" />'; echo '<link rel="stylesheet" type="text/css" href="../css/images.css" />'; include '../includes/connect.php'; include '../includes/vars/images.var.php'; include '../includes/functions/images.func.php'; $group_id = grab_group_id2($db, $album_name); $dir = 'upload/hello/'; $per_row = 16; if(file_exists($dir) == FALSE){ echo 'Sorry, but the folder' . $dir . ' does not exist!'; }else{ $dir_contents = scandir($dir); echo '<div class="images_container">'; foreach ($dir_contents as $file) { $explode_image_filename = explode('.', $file); $file_type = strtolower(end($explode_image_filename)); if($file !== '.' && $file !== '..' && in_array($file_type, $ext) == TRUE){ if($counter % $per_row === 0 && $counter !== 0){ break; } echo '<a href="' . $dir . '/' . $file . '" alt="' . $file . '"><img src="' . $dir . '/thumbs/thumb_' . $file . '" alt="' . $file . '" class="images" /></a>'; $counter++; } } echo '<br /><a href="more_images.php?id='.$group_id.'" class="more-images-link">More Images...</a>'; } ?>

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.