Jump to content

crashwave

Members
  • Posts

    14
  • Joined

  • Last visited

About crashwave

  • Birthday April 26

Profile Information

  • Gender
    Not Telling

crashwave's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes exactly but I do not know the file is /image.jpg until after main_folder()."/image.jpg" is already requested. the way the code is echo '<img src="'. main_folder() . '/image.jpg">'; but it could be anything /file.pdf, anotherphp.php How do I get the file that is requested after main_folder() function to figure out if that file exists in fork_folder. doing a file exists is easy if I knew what file it's looking for at the time.
  2. Thanks for reply. Yes most of the code is outside the folders but not fork_folder either. I haven't used Joomla/Wordpress in a while but I think it could be considered similar to their module/template structure. say the main code requests the module folder file, but there are forks/children of the module with changes. they are not totally duplicates of the module just change a few things in it. The easiest thing is say an image. wordpress I think sees the main_module and gets it's files. say it calls $main_folder./image.png but I want it to get $fork_folder./image.png instead if that one exists. But the way it is written in the main code is the problem I cannot figure out how to get the filename because it's usually echo/return/include main_folder() . 'filename'
  3. yes denno020, but how do I get the file to begin with to check if it exists. That is main, 1st hurdle. I need main_folder().'filepath'; to be changed to fork_folder().'filepath'; whenever main_folder() is called in the code which is outside the folders. I have it working if I specify filepath using function hme_url($file) { $file = ltrim( $file, '/' ); if ( empty( $file ) || ( false !== strpos( $file, '..' ) ) ) { //??? $url = trailingslashit(main_folder());//main or fork } elseif (forks_avail() && file_exists( trailingslashit( fork_folder() ) . $file ) ) { $url = trailingslashit( fork_folder() ); } else { $url = trailingslashit( main_folder() ); } return $url.$file ; } can be prob written better with globals and change main_folder() in the function but that isn't the main issue. Getting the $file part that is after the main_folder() request is the problem. Then I have to deal with going back after getting $file and replacing the whole string with fork_folder(). $file. figuring out if it exists is the easy part.
  4. Hello all I need your help with a code we are rewriting/updating files are scattered amongst several folders, one folder is the main folder (original). all folders have the same folder structure and most having identical file NAMES as the main folder. Those with identical file names are NOT, usually, the same file; they have been edited by the owner of that folder. Think of it like git master/original and forks/branches. the code we have accesses files in EITHER the main folder or the 'forks' using a function that returns the directory like this main_folder().'filepath'; OR fork_folder().'filepath'; or at times like this <?php echo main_folder(); ?>filepath what I need is to change main_folder() to equal fork_folder() but only if 'filepath' exists in that folder, if it doesn't then main_folder() does not change. So essentially whenever main_folder() is called I need to find what comes after it ; ?> Or ;?> OR .' get the file that follows, IF ANY, figure out if it exists in fork and change main_folder() or not. It was suggested to me that the only way to do this is to incorporate js in the code. But there has to be a completely php way do this. it would have been much easier if main_folder() and fork_folder() were changed to main_folder('filepath') fork_folder('filepath') but that is not an option. Thanks for any input.
  5. I tutor at the university and we want to keep track of student grades for certain classes to see what classes need more attention. We have created the DB and have queries running successfully except this one that has me stumped We have (example) Year Semester Course Section Grade 2010 Spring 1001 02 A 2010 Spring 1001 02 F 2010 Spring 1001 01 C 2010 Spring 1001 02 A 2010 Spring 1002 03 B 2010 Spring 1001 02 A 2010 Spring 1001 04 W .... We want to calculate the % students who received an A, B or C in each CLASS (Total ABC/Total Students) We have it calculating the total students and the total passing, but I cannot to give me both the total student AND the total ABC with the same statement What we want is something like Semester Class Total Pass % 201003 1001 01 39 31 31/39 Any Help appreciated Thanks
  6. I totally understand. I did not want anyone to actually solve my probs. Just needed an idea or somehting what I was doing wrong right. There were many other problems, I would have asked many more questions if that were the case. Anyway like I said it is done and over with so this is not for a grade, and it may someday be someones real-world-issue
  7. Yes the project assignment is over. Had to turn it in last week. turned in what I had which that one did what the question wanted but since there were more than one 'name's with a high score it SHOULD HAVE showed them all. I would like to find a way to do it anyway, for later, so I know how/where I messed up. Does it matter
  8. Sorry for late update/response... FINALS The output needed is this TOURN_ID | CLUB_NAME | POINT 1 | Club 6 | 15 2 | Club 3 | 20 2 | Club 4 | 20 3 | Club 1 | 22 4 | Club 2 | 15 4 | Club 5 | 15 4 | Club 6 | 15 5 | Club 4 | 20 The output I currently have TOURNID | NAME | POINTS 1 | A | 25 2 | B | 21 3 | C | 23 4 | D | 21 . . . However many Tourn_ID's there are with this query SELECT t.TOURN_ID Tournament, t.CLUB_NAME 'Club Name', t.TOURN_POINTS POINTS FROM (SELECT t.TOURN_ID, c.CLUB_NAME AS CLUB_NAME, SUM(p2m.POINTS) TOURN_POINTS, t.TOURN_START FROM PLAYER2MATCH p2m JOIN MATCH2TOURNAMENT m2t ON p2m.M2T_ID = m2t.M2T_ID JOIN PLAYER2CLUB p2c ON p2m.P2C_ID = p2c.P2C_ID JOIN TOURNAMENTS t ON m2t.TOURN_ID = t.TOURN_ID JOIN CLUBS c ON p2c.CLUB_ID = c.CLUB_ID GROUP BY t.TOURN_ID, c.CLUB_ID ORDER BY t.TOURN_ID , TOURN_POINTS DESC) AS t WHERE YEAR(t.TOURN_START) = 2010 GROUP BY t.TOURN_ID it only shows 1 score for each tourn. I need all the names with the same high score. since the project is over here is the model http://picasaweb.google.com/amommy/Mysql?authkey=Gv1sRgCIe47KrJqf2QpAE#5548404928863439954 here is the db https://docs.google.com/leaf?id=0BygKF_ts9C6KYjQ1MWRjZTMtMDBkOS00NmM4LThiNzMtZWJjOGY4OTRmNDA1&hl=en&authkey=CNqBjJwL Thanks
  9. But there are times where more than one club gets the high score and the number of rows need to be more than the # of tourn. TOURN_ID | CLUB_NAME | POINT 1 | Club 6 | 15 2 | Club 3 | 20 2 | Club 4 | 20 3 | Club 1 | 22 4 | Club 2 | 15 4 | Club 5 | 15 4 | Club 6 | 15 5 | Club 4 | 20 Need to show all highest/'tourn scores like above. How do I make it show up all clubs that got the same highest score.
  10. I have made somewhat of a breakthrough I have it giving me TOURN_ID | CLUB_NAME | POINT for the highest score/club/tourn. so only the number of tourn is returned not each score for each club in each tourn as before. But there are times where more than one club gets the high score and the number of rows need to be more than the # of tourn. TOURN_ID | CLUB_NAME | POINT 1 | Club 6 | 15 2 | Club 3 | 20 2 | Club 4 | 20 3 | Club 1 | 22 4 | Club 2 | 15 4 | Club 5 | 15 4 | Club 6 | 15 5 | Club 4 | 20 Here is the query, it is a mess. SELECT tournaments.TOURN_ID, tournaments.CLUB_NAME, tournaments.TOURN_POINTS FROM (SELECT TOURNAMENTS.TOURN_ID, CLUBS.CLUB_NAME AS CLUB_NAME, SUM(PLAYER2MATCH.POINTS) TOURN_POINTS FROM PLAYER2MATCH, MATCH2TOURNAMENT, PLAYER2CLUB, TOURNAMENTS, CLUBS WHERE PLAYER2MATCH.M2T_ID = MATCH2TOURNAMENT.M2T_ID AND PLAYER2MATCH.P2C_ID = PLAYER2CLUB.P2C_ID AND MATCH2TOURNAMENT.TOURN_ID = TOURNAMENTS.TOURN_ID AND PLAYER2CLUB.CLUB_ID = CLUBS.CLUB_ID GROUP BY TOURNAMENTS.TOURN_ID, CLUBS.CLUB_ID ORDER BY TOURNAMENTS.TOURN_ID , TOURN_POINTS DESC) AS tournaments GROUP BY tournaments.TOURN_ID Any thoughts PLEASE.
  11. Wasn't sure whether or not to unsolve my other question even though it was solved. http://www.phpfreaks.com/forums/mysql-help/one-query-to-find-result-from-multiple-tables/. "Clubs enter tournament. Each club has 5 players with a rank to play same ranked players from other clubs. Each player plays match(es) in each tournament and gets a score (0,1,2 points) There are many tournaments each with many matches." Model Here http://picasaweb.google.com/lh/photo/s6b82nLc84H5awZhcy-GIig4DBDpe4IEPAbqDkhUXMw (names not the same as current DB like match2player changed to player2match) I have SELECT t.TOURN_ID AS TOURNAMENT, c.CLUB_NAME AS 'CLUB NAME', SUM( p2m.POINTs ) AS POINTS FROM PLAYER2MATCH p2m JOIN PLAYER2CLUB p2c ON p2m.P2C_ID = p2c.P2C_ID JOIN CLUBS c ON p2c.CLUB_ID = c.CLUB_ID JOIN MATCH2TOURNAMENT m2t ON p2m.M2T_ID = m2t.M2T_ID JOIN TOURNAMENTS t ON m2t.TOURN_ID = t.TOURN_ID WHERE t.TOURN_ID = 1 GROUP BY c.CLUB_ID ORDER BY POINTS DESC Which lists the points received by each CLUB_NAME per TOURN_ID input in the where clause. What I needed (just found out) is to list only the ones with the MAX point for each TOURN_ID So it would be like this TOURNID | NAME | POINTS 1 | A | 25 2 | B | 21 3 | C | 23 4 | D | 21 . . . However many Tourn_ID's there are Any ideas please, Thanks
  12. I actually like yours a lot better, little tweaking here it is SELECT c.Club_name, SUM( m.POINTs ) AS TPoints, t.tourn_id FROM match2player m JOIN player2club p ON m.P2C_ID = p.p2c_id JOIN clubs c ON p.club_id = c.club_id JOIN match2tournament d ON m.m2t_id = d.m2t_id JOIN tournaments t ON d.tourn_id = t.tourn_id WHERE t.tourn_id = $tournamentid GROUP BY c.Club_ID ORDER BY TPoints DESC
  13. I put the image here http://picasaweb.google.com/lh/photo/s6b82nLc84H5awZhcy-GIig4DBDpe4IEPAbqDkhUXMw for reference deleting it later this week. The point_list just has point 0,1,2 and what they mean Loss,Draw,Win Thanks I did something similar without JOINS (they confuse me) Need to try with Joins I Used SELECT tournaments.TOURN_ID, clubs.Club_Name, SUM(match2player.POINTS) AS Tourn_Points FROM match2player, match2tournament, player2club, tournaments, clubs WHERE match2player.M2T_ID = match2tournament.M2T_ID AND match2player.P2C_ID = player2club.p2c_ID AND match2tournament.TOURN_ID = tournaments.TOURN_ID AND player2club.Club_ID = clubs.club_id GROUP BY tournaments.TOURN_ID, clubs.club_id It displayed the Tournament_ID | Club Name | Tourn_Points more tweaking and I can get just the highest. or just tourn by user input.
  14. I had to create a 3NF model and Database from a single spreadsheet. Here is what I came up with http://picasaweb.google.com/lh/photo/jOrl3AZM0wWGLVK4roxUaCg4DBDpe4IEPAbqDkhUXMw database has been created and all data inserted. Description Clubs enter tournament. Each club has 5 players with a rank to play same ranked players from other clubs. Each player plays match(es) in each tournament and gets a score (0,1,2 points) There are many tournaments each with many matches. What I need is 1 query to find the club with the most points in a tournament. I have the logic I think Get total points for each player in a tournament. Group them by club. find sum of all club players. So I need the output to be +-------+---------+ |CLUB |POINTS | +-------+---------+ | Club1 | 10 | | Club2 | 20 | | Club3 | 30 | Or just the highest club. But nothing I do works. Any ideas please? also any input on model/DB appreciated. Thanks
×
×
  • 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.