Jump to content

@

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Everything posted by @

  1. my guess (without seeing any code) is that your browser is storing the values and is auto filling the form as for you second question if($variable) checks if the value of the variable is true (or the equivalent of true) isset($variable) checks if the variable has been initialised empty($variable) checks if the variable has been initialised and has a value
  2. im assuming your posts are stored in a database? if each post has a date that it was posted then you could sort them in from the database. If you post the table structure i'll have a better idea
  3. add this print_r($arrGamescount); die(); below this line $arrGamescount = $games->myGamesCount($prefix, $uid); and post the output please
  4. are you calling session_start(); on both the process.php and index.php pages?
  5. any reason why you would not just do this? <?php $sourceURL = $link; $metaData = get_meta_tags($sourceURL); foreach($metaData as $key => $val) { echo "$key => $val<br />"; } ?>
  6. can you post what is posted when you submit the form and the relevant code so we can get a better idea of what you are trying to do.
  7. The issue is that your getSkillData function returns the first match in the statss array. I think you may need to re-work the way the you build your data in order to fix it - maybe something like this: :page file <?php require_once('leaderboard_functions.php'); $initialise = false; $skills = array('overall', 'attack', 'defense', 'strength', 'constitution', 'ranged', 'prayer', 'magic', 'cooking', 'woodcutting', 'fletching', 'fishing', 'firemaking', 'crafting', 'smithing', 'mining', 'herblore', 'agility', 'thieving', 'slayer', 'farming', 'runecrafting', 'hunter', 'construction', 'summoning', 'dungeoneering'); if(isset($_GET['track'])) { $initialise = true; } $skillIndex = empty($_GET['skillIndex']) ? 0 : $_GET['skillIndex']; $leaderboard = generateLeaderboard($skillIndex, $initialise); ?> <!DOCTYPE HTML> <html> <head> <title>Fight Tracker</title> <link rel="stylesheet" href="style.css"> </head> <body> <div align="center"> <img src="http://www.runehead.com/clans/banners/clansolace-6617078.png"> <table id="atable"> <thead> <tr> <th scope="col">Username</th> <th scope="col">Skill</th> <th scope="col">Level</th> <th scope="col">Starting experience</th> <th scope="col">Ending experience</th> <th scope="col">Gained experience</th> </tr> </thead> <tbody> <?php foreach($leaderboard as $player => $stats) { print '<tr>'; print '<td class="odd">'.$player.'</td>'; print '<td class="odd">'; print '<img src="images/'.$skills[$skillIndex].'.png">'; print '</td>'; print '<td class="odd">'.number_format($stats['level']).'</td>'; print '<td class="odd">'.number_format($stats['startingExperience']).'</td>'; print '<td class="odd">'.number_format($stats['currentExperience']).'</td>'; print '<td class="odd">'.number_format($stats['experienceGained']).'</td>'; print '</tr>'; } ?> </tbody> </table> </div> <br> <form name="skill_select" action="" method="GET"> <div align="center"> <font color="#03F">View a different skill: </font> <select name="skillIndex"> <?php foreach($skills as $key => $skill) { print '<option value="'.$key.'">'.$skill.'</option>'; } ?> </select> <input type="submit" value="View" /> </div> </form> </body> </html> :functions file <?php function connectToDatabase() { $database = mysql_connect("mysql.alwaysdata.com", "*", "*"); if(!$database) { die('Could not connect to database: ' . mysql_error()); } mysql_select_db("tracker_tkoblitz", $database); return $database; } function startTracker($username, $stats) { $query = " INSERT INTO stats ( username, stats ) VALUES ( '".mysql_real_escape_string($username)."', '".mysql_real_escape_string($stats)."' )"; mysql_query($query); } function grabStats($username) { $query = " SELECT stats FROM stats WHERE username = '".mysql_real_escape_string($username)."' LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_array($query); return $row['stats']; } function generateLeaderboard($participants, $skillIndex, $initialise) { $database = connectToDatabase(); $participants = array('Quuxx', 'Aeterna', 'Ts Danne', 'Marsman', 'PFC Mage'); $leaderboard = array(); //sort in reverse as the uasort below will reverse the order rsort($participants); foreach($participants as $key => $name) { $currentStats = getStats($name); if($initialise) { //start the tracker for each participant as we go startTracker($name, $userStats); } //fetch saved statistics from the database $startingStats = grabStats($name); //set the rank level and experience for this skill from the database list($startingRank, $startingLevel, $startingExperience) = getSkillAttributes($startingStats, $skillIndex); //set the rank level and experience for this skill from the current data list($currentRank, $currentLevel, $currentExperience) = getSkillAttributes($currentStats, $skillIndex); //calcuate the experience gained $gainedExperience = $currentExperience - $startingExperience; //add the data to an array $leaderboard[$name] = array('level' => $currentLevel, 'startingExperience' => $startingExperience, 'currentExperience' => $currentExperience, 'experienceGained' => $gainedExperience); } //sort the leader board by gained experience uasort($leaderboard, 'compare'); mysql_close($database); return $leaderboard; } function compare($a, $b) { if ($a['experinceGained'] == $b['experinceGained']) { return 0; } return ($a['experinceGained'] < $b['experinceGained']) ? -1 : 1; } function read($file) { if(($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { for($c = 0; $c < count($data); $c++) { $lines[] = $data[$c]; } } fclose($handle); } return $lines; } function getStats($username) { $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, "http://hiscore.runescape.com/index_lite.ws?player=".$username); curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0", rand(4, 5))); curl_setopt ($curl, CURLOPT_HEADER, (int) $header); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($curl, CURLOPT_VERBOSE, 1); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $output = curl_exec($curl); curl_close ($curl); if(strstr($output, "<html><head><title>")) { return false; } return $output; } function getSkillAttributes($stats, $index) { $skills = explode("\n", $stats); $skill = explode(',', $skills[$index]); return $skill; } ?>
  8. thats because auto increment will never reuse the same increment twice - it enforces referential integrity. you can reset it by using truncate but that will remove ALL of the data from the table.
  9. you will have to use javascript. look at set_interval or set_timeout to make this happen. FYI thought - having a page that refreshes every minute is gonna be annoying as hell!! A better solution would be to use ajax to process the form in the background and not refresh the page all the time.
  10. Add some debug lines inside your foreach loop to check that it is behaving as expected. But at a glance id say that either the array_push function isn't getting called or an error occurs before the processor reaches that line of code
  11. maybe you could ask it nicely? post some code and lets have a proper look at it, eh?
  12. are you using $_GET or $_POST to fetch the values for the variables: seems like you are trying to use both at the same time?!? $id=$_POST['cat']; //Passed from URL directory ID from table $name=$_POST['subcat']; //Passed from URL image name from table $path = $_GET['directory']; $name=$_GET['subcat'];
  13. hmm i think you will find that one of the 'Product' values has a leaded or trailing space which is why you get not sure how to fix your functions but if you are interested the below will give you the result you are after: $string = "Product 1, Product 2, Product 3, Product 4, Product 5, Product 6, Product 7, Product 8, Product 9, Product 10, Product 11, Product 12, Product 13"; preg_match_all('/(?<=, ).*?(?= [0-9])|^.*?(?= [0-9])|([0-9].*?(?=,))/', $string, $matches); $uniqueValues = implode(',', array_unique(array_values($matches[0]))); print_r($uniqueValues);
  14. any chance the event name for the first row is empty? otherwise id say the issues is in your query.
  15. have you tried printing the $sql variable to the screen to see if it looks ok? my guess is that the contents of the $imgContent variable is causing the problem. Maybe try calling mysql_real_escape_string() in it before inserting in into the query string
  16. How about something along these lines? //get the file contents $calllog=file('CallLog/OfficeLine'); //sort the file arsort($calllog); //initialise a variable to hold the database file contents $storage = array(); //get text file contents $database = file('db.txt'); //sort the file arsort($database); foreach($database as $line) { //make an array of the values $row = explode(',', $line); //add the data to the storage variable $storage[(int)$row[1]] = $row[0]; } foreach($calllog as $callLine) { //initialise the storage variable $matches = array(); //find the name and number preg_match_all('/(?<=Name\=).*?(?=,)|(?<=Number\=)[0-9].*?(?=\))/', $callLine, $matches); //make sure we remove any trailing spaces $name = trim($matches[0][0]); //cast the number to an int $number = (int)$matches[0][1]; //if the number exists in the storage variable and the name is also the same -> we have a match if(in_array($number, array_keys($storage)) && $name == $storage[$number]) { echo "<font face=Arial, Helvetica, sans-serif size=2 color=red>"; echo $number; echo "</font>"; } else { echo "false"; } }
  17. what does the structure of the table that stores the data look like? more specifically i guess do the subheaders have and reference to the headers that they belong to?
  18. Im assuming that you dont have access to the folder that they are stored in on the webserver, right? Without getting over complicated about it , you could open firefox -> search for and intall an add-on called Down Them All (its a download manager for firefox). Once installed (and after restarting firefox of course) load the page at http://www.automation.siemens.com/bilddb/content.aspx?NodeID=1000000&UseStructure=&lang=en, set the number of items per page to to max available, open down them all (tool -> down them all), set you options and away you go. Now thats gonna take you a while to get through all of the pages but it will download all of the images on each page once it starts. Hope that helps some.
×
×
  • 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.