Jump to content

pein87

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pein87's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Since the extension is given in the files name you can just substr that from the file name. Or you could regex it to return everything after the . but you'd need to check its distance for the end of the string to be sure its accurate.
  2. You can if your trying to do multi deletes using html. Set you checkbox input tag's name attribute to myName[] or as an example <form action="del.php" method="post"> <input type="checkbox" name="ids[]" value="1" /> <input type="checkbox" name="ids[]" value="2" /> </form> $ids = $_POST['ids']; foreach($ids as $id) { echo $id . "<br />"; } There are other methods though and you may google for a function that allows you to do that or write your own.
  3. In order to tell a page you came from another page you need to append a get variable with the page name in it and have the other pages check if for that variable. Its best to encode the variables data into something decodeable so you can get which page sent the user to this page or you could add the $_SERVER['HTTP_REFERER'] variable which is send as a header and could then be check per page and reset but that can get tricky. Best bet is to expect a get variable and if it not found show standard page. No need fr sessions unless you require them to login.
  4. You can get percentage with this function function percent($score,$totNum) { if(is_numeric($score) && is_numeric($totNum)) { return ($score / $totNum) * 100; } else { return 0; } You can create a function to handle the subtraction as well as returning the percent and score. Make sur ethe percent function is one the same page or included and you'll get an array with the keys score and percent. function score($totNum,$numMissed,$retPer=0) { if(is_numeric($totNum) && is_numeric($numMissed)) { $score = $totNum - $numMissed; if($retPer == 0) { return $score; } else { $per = percent($score,$totNum); $scores = array("score" => $score,"percent" => $per); return $scores; } } } As far as checking scores you need to compare answers by comparing the answers to a dictionary of answers for that question/list of questions. How you implement this is up to you but most just make two arrays and compare each ones values.
  5. You could use the mysql_num_rows function to check if the returned rows is greater then 0. if(mysql_num_rows($result) > 0) { //greater then 0 some rows return lets get some data while($team = mysql_fetch_assoc($result)) { //echo something here using $team['field_name_here'] } } else { //trigger no data error }
  6. Hello, I was trying to help someone out on another site and found that I needed some help myself. I wrote a function that gets the count of both files and folders in a directory. The problem is that it doesn't get sub directories and their file count. While it is doing that I'd like it to get the file size of each file as it goes through the loop. Does anyone know how to do this or how I could implement it so I get the desired effect? Here is what I got so far. It works but it doesn't do sub folders and their files and sub folders. <?php function fileCount($p,$s = "/") { $pL = strlen($p); // length of the path string $pE = substr($p,$pL - 1, $pL);// holds if the end value is / or not. $dC = 0; // used to hold the count of folders $fC = 0; // holds the count of files. $h = ''; $f = ''; if($pE == $s) { // person added delimter for path lets get to work without adding the delimter in code $h = opendir($p); while(($f = readdir($h)) !== false) { //loop through the directory and create counters if($f != "." && $f != "..") { // make sure the value of $f does not equal . or .., since it doesnt we check if each value is a file or folder if(is_dir($p . $f)) { $dC++; } else if(is_file($p . $f)) { $fC++; } } } $l = array($dC,$fC); return $l; } else { // person added delimter for path lets get to work without adding the delimter in code $h = opendir($p . $s); while(($f = readdir($h)) !== false) { //loop through the directory and create counters if($f != "." && $f != "..") { // make sure the value of $f does not equal . or .., since it doesnt we check if each value is a file or folder if(is_dir($p . $s . $f)) { $dC++; } else if(is_file($p . $s . $f)) { $fC++; } } } $l = array($dC,$fC); return $l; } } MOD EDIT: code tags added.
  7. Hiya I was wondering how one would get make dynamic url variable value pairs from a databases fields. I have a database that I want to use to store variable value pairs that will be used on my pages for dynamic content. It will check one thing for certain besides if the variable value pair match. The table looks like this rpg loc_type loc_type template I want it to check if the rpg is in an array and then check if the url variable and value pair match on from the database. I dont know much about auto code that would generate this on its own and I'm not sure if you can say $_GET[$location]; I dont want to hard code it so it only works with what i code I want the urls variable value pair to be based on the database info which determines which template to show based on those values.
×
×
  • 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.