Jump to content

egiblock

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by egiblock

  1. i have this to generate a list of users and dates. just need to get the grouping and the logic down now.. <?php include 'includes/db.inc.php'; $result = mysqli_query($link, 'SELECT * FROM employeelog LIMIT 0 , 30' ); $ii=0; while ($row = mysqli_fetch_array($result)) { for($fst=0;$fst<$ii;$fst++){ $tr1name[$ii] = $row['name']; $tr1direction[$ii] = $row['direction']; $tr1dated[$ii] = $row['dated']; $tr1datet[$ii] = $row['datet']; } $ii++; } ?> Report Generation<br /><br /> <table> <tr> <td>name</td> <td>date</td> <td>In</td> <td>Out</td> <td>In</td> <td>Out</td> <td>In</td> <td>Out</td> </tr> <?php for($fst=0;$fst<$ii;$fst++){?> <tr> <td>a<?php echo $tr1name[$fst];?></td> <td>a<?php echo $tr1dated[$fst];?></td> </tr> <?php }?> </table> </head> </html>
  2. hello, I have an employee in / out board that someone else coded, and I am trying to generate a report from a table of data. I have the logic in my head, just not sure how to get it down to work correctly. It's currently written in PHP with a mysql database backend. For example. Data Table: ---------------------------------------------------------------- ID - NAME - DIRECTION - DATED - DATET ---------------------------------------------------------------- 37 Employee1 2 2012-09-09 20:53:25 37 Employee1 1 2012-09-09 20:53:33 39 Employee2 2 2012-09-10 07:58:51 37 Employee1 2 2012-09-10 09:08:56 39 Employee2 1 2012-09-10 17:03:29 37 Employee1 1 2012-09-10 17:10:47 37 Employee1 2 2012-09-11 08:14:14 39 Employee2 2 2012-09-11 08:14:22 37 Employee1 1 2012-09-11 12:51:59 39 Employee2 1 2012-09-11 12:53:12 37 Employee1 2 2012-09-11 14:44:26 39 Employee2 2 2012-09-11 14:44:36 39 Employee2 1 2012-09-11 14:44:36 39 Employee2 2 2012-09-11 14:44:36 39 Employee2 1 2012-09-11 16:43:59 37 Employee1 1 2012-09-11 17:16:26 ---------------------------------------------------------------- Direction (From Above) 1 = Out 2 = In ----------------------------------------------------- I'm going to create a couple of different reports, but the first one will look like: Name Date Time In Time Out Time In Time Out Total Time: --------------------------------------------------------------------------------------- Employee1 9/9/12 20:53 20:53 0:00 9/10/12 09:08 17:10 8:02 9/11/12 08:14 12:51 14:44 17:16 7:09 ----------- 15:11 Employee2 9/10/12 7:58 17:03 9:05 9/11/12 8:14 12:53 14:44 16:43 7:11 ----------- 16:16 can someone point me in the right direction for this ? thanks
  3. first line of code should read add_action('the_content','scoring_insert'); it's working now.
  4. I've created the initial page, and got it to show up in the main plugin list, and can activate and deactivate it. Then I have a page with the code {GOLFSCORE} as the content of the page, and that's the only thing that shows when you click on that specific page (as it should). The code is supposed to replace the {GOLFSCORE} with my programming (in this code, it's the old 'Hello World'). But my code isn't doing anything and i can't see what's wrong with it. add_action('init','scoring_insert'); // Function to deal with loading the Golf Scoring Code into pages function scoring_insert($content) { if (preg_match('{GOLFSCORE}',$content)) { $golf_output = GolfScoringSystem(); $content = str_replace('{GOLFSCORE}',$golf_output,$content); } return $content; } function GolfScoringSystem() { $golf_body .= 'Hello World'; return $golf_body; }
  5. it was the $row compared to $row_playerdetail that threw me off. this code works.. <?php if($PlayerDetail) { echo "<tr><td>"; echo date('M j, Y g:i a', strtotime($row_PlayerDetail['eventDateTime'])); echo "</td><td>"; echo $row_PlayerDetail['CourseName']; echo "</td><td>"; echo $row_PlayerDetail['eventName']; echo "</td><td>"; echo $row_PlayerDetail['totalScore']; echo "</td></tr>"; } while($row = mysql_fetch_array($PlayerDetail)) { echo "<tr><td>"; echo date('M j, Y g:i a', strtotime($row['eventDateTime'])); echo "</td><td>"; echo $row['CourseName']; echo "</td><td>"; echo $row['eventName']; echo "</td><td>"; echo $row['totalScore']; echo "</td></tr>"; } ?> i also took out the first "where" statement, and i finally got it !!! thanks !!!!! 8)
  6. thanks.. i'll have to look at it some more again tomorrow... i can get it sometimes to display the 1st record, and nothing else, and then the 2-whatever records another time, but not the first... so i'll have to check it out when i have a clear head.
  7. $query_PlayerListName = "SELECT * FROM tbl_players WHERE tbl_players.playerID = $id"; $PlayerListName = mysql_query($query_PlayerListName, $golfscoring) or die(mysql_error()); $row_PlayerListName = mysql_fetch_assoc($PlayerListName); $totalRows_PlayerListName = mysql_num_rows($PlayerListName); $query_PlayerDetail = "SELECT tbl_players.playerID, tbl_courses.CourseName, tbl_events.eventName, (tbl_scores.s1 + tbl_scores.s2 + tbl_scores.s3 + tbl_scores.s4 + tbl_scores.s5 + tbl_scores.s6 + tbl_scores.s7 +tbl_scores.s9 + tbl_scores.s8 + tbl_scores.s12 + tbl_scores.s11 + tbl_scores.s10 + tbl_scores.s18 + tbl_scores.s17 +tbl_scores.s16 + tbl_scores.s15 + tbl_scores.s14 + tbl_scores.s13) AS totalScore, tbl_events.eventDateTime, tbl_players.PlayerName FROM tbl_scores Inner Join tbl_courses ON tbl_scores.courseID = tbl_courses.courseID Inner Join tbl_players ON tbl_players.playerID = tbl_scores.playerID Inner Join tbl_events ON tbl_scores.eventID = tbl_events.eventID WHERE tbl_scores.playerID = $id"; $PlayerDetail = mysql_query($query_PlayerDetail, $golfscoring) or die(mysql_error()); $row_PlayerDetail = mysql_fetch_assoc($PlayerDetail); $totalRows_PlayerDetail = mysql_num_rows($PlayerDetail); in my html document i have: <b> <?php echo $row_PlayerListName['PlayerName']; ?> </b> <br><br> then for the results i have the following table: <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td align="center"><strong>Date of Event</strong></td> <td align="center"><strong>Course Name</strong></td> <td align="center"><strong>Event Name</strong></td> <td align="center"><strong>Total Score</strong></td> </tr> <?php if($PlayerDetail) { while($row = mysql_fetch_row($PlayerDetail)) { echo "<tr><td>"; echo date('M j, Y g:i a', strtotime($row['eventDateTime'])); echo "</td><td>"; echo $row['CourseName']; echo "</td><td>"; echo $row['eventName']; echo "</td><td>"; echo $row['totalScore']; echo "</td></tr>"; } while($row2 = mysql_fetch_array($PlayerDetail)) { echo "<tr><td>"; echo date('M j, Y g:i a', strtotime($row2['eventDateTime'])); echo "</td><td>"; echo $row2['CourseName']; echo "</td><td>"; echo $row2['eventName']; echo "</td><td>"; echo $row2['totalScore']; echo "</td></tr>"; } } ?> </table> all that is displaying on the page is the date "eventDateTime" in the table, and the echo'd player name at the top of the page, but nothing else. any ideas ?
  8. actually i got it fixed. i copied the code from a previous filed, and never changed the name.. $query_AddEventGetType = "SELECT tbl_eventtype.typeID, tbl_eventtype.TypeName\n" . "FROM tbl_eventtype\n" . "WHERE tbl_eventtype.typeID = $evtype"; $AddEventGetType = mysql_query($query_AddEventGetType, $golfscoring) or die(mysql_error()); ?> <br /> <?php $evyear = date('Y', strtotime($_POST['eventDateTime'])); $evtitle = $_POST['customEventName']; $fixedEventName = ($evyear . " - " . mysql_result($AddEventGetType,0,1) . " - " . $evtitle) ; echo 'Trying to do the following: eventName = year - type - eventname<br><br>';
  9. actually once the event name is entered into the database, the event name won't change. the reason for the event joining names is that a name could stay the same through out years, so to differentiate between years i want to put the year - type - and then the name. plus it will show up this way when listing all of the events in a drop down box. the input form is the following when filled out: Event Date / Time: <input type="text" name="eventDateTime" value="07/30/09 12:36:58 PM"/> Course Played: <select name="CourseID"> <option value="2">Black Brook Country Club</option> </select> Event Type: <select name="EventTypeID"> <option value="3">Summer Tournament</option> </select> Give the Event a Name: <input name="customEventName" type="text" value="* Be Descriptive*" /> so the variables that i am passing to the next page is: CourseID = 2 EventTypeID = 3 eventDateTime = current date and time so then on the next page, the goal is to query the database and match the eventypeid (2) to the record in the database. but then i am having a problem pulling the 1 variable from the database.
  10. i'm new to php, and am stuck now.. what's happening is that a user is filling out a form with: Enter the Date /Time of the Event: (eventDateTime) Course Played: (CourseID) Event Type: (EventTypeID) Give the Event a Name:(customEventName) when they submit, i want to create a custom name before it submits it to the database. .. db connection remove, but it's working fine....... $evtype = $_POST['EventTypeID']; $query_AddEventGetType = "SELECT tbl_eventtype.typeID, tbl_eventtype.TypeName\n" . "FROM tbl_eventtype\n" . "WHERE tbl_eventtype.typeID = $evtype"; $AddEventGetType = mysql_query($query_EventTypeListing, $golfscoring) or die(mysql_error()); ?> <br /> <?php $evyear = date('Y', strtotime($_POST['eventDateTime'])); $evtitle = $_POST['customEventName']; $fixedEventName = ($evyear . " - " . mysql_result($AddEventGetType,1) . " - " . $evtitle) ; ?> what i am ultimately trying to do is create a variable '$fixedEventName' to look like: year - type - eventname or 2009 - NonLeague Play - Playing with friends. but i am getting the actual value of the "nonleague play" of 2 so my line looks like the following: 2009 - 2 - Playing with friends.
  11. honestly i just started working with php about 2 weeks ago.. i have no clue what i am doing.. but i got it now. thanks !
  12. i'm pulling hole scores from a database. variable names are h1,h2,h3.....etc.... so my database pull code for display is: <?php echo $row_CourseDetail['h1']; ?> but i also want to generate hidden form values for this at the same time. so i was trying this: <script type="text/javascript"> <!-- Calculate the Scores for Hole Calculations var i=1; var j=18; var ParScore = new Array(); while (i<=j) { document.write('<input type="hidden" value="<?php echo $row_CourseDetail['h1']; ?>">'); i++; } </script> ovbiosusly i want the "h1" variable name in there to be different depending on the loop it's going through. so it should be h + variable 'i' but i can't get the code to process right. any ideas ?
  13. here's the final code that worked. thanks for the help. this php stuff is all new to me $ecid = $_GET['ecid']; mysql_select_db($database_golfscoring, $golfscoring); $query_EventListing = "SELECT * FROM tbl_events WHERE tbl_events.eventCourseID = $ecid" ;
  14. i have a javascript that passes a variabe from a form to another window for processing.. form: ... <form name="CourseSelection"> <select name="selectedCourseID" onChange="pullCourse();" id="selectedCourseID"> <option value="0" selected>Select a Course</option> ....... pullcourses.js: ........ ajaxRequest.open("GET", "geteventtoaddscore.php?ecid=" + document.getElementById('selectedCourseID').value, true); ........ it passes the line: http://localhost/test1/geteventtoaddscore.php?ecid=3 getevent...php: <?php $ecid = $_POST['ecid']; mysql_select_db($database_golfscoring, $golfscoring); $query_EventListing = "SELECT * FROM tbl_events WHERE $ecid = tbl_events.eventCourseID" ; it is throwing the error from the above sql statement. Notice: Undefined index: ecid in C:\wamp\www\test1\geteventtoaddscore.php on line 4 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= tbl_events.eventCourseID' at line 1
  15. i figured that out so far, which was good for me to figure out early.. i'm more concerned with all of the code per query. just for displaying two result tables with calculations, i have the following: ** please note it's for a golf scoring system... <?php require_once('golfscoringdbcon.php'); ?> <?php mysql_select_db($database_golfscoring, $golfscoring); $query_CourseDetail = "select * from tbl_courses WHERE $id = tbl_courses.courseID"; $CourseDetail = mysql_query($query_CourseDetail, $golfscoring) or die(mysql_error()); $row_CourseDetail = mysql_fetch_assoc($CourseDetail); $totalRows_CourseDetail = mysql_num_rows($CourseDetail); mysql_select_db($database_golfscoring, $golfscoring); $query_EventListingByCourse = "SELECT tbl_events.eventID, tbl_events.eventName, tbl_events.eventDateTime, tbl_events.eventCourseID FROM tbl_events WHERE $id = tbl_events.eventCourseID ORDER BY eventDateTime DESC"; $EventListingByCourse = mysql_query($query_EventListingByCourse, $golfscoring) or die(mysql_error()); $row_EventListingByCourse = mysql_fetch_assoc($EventListingByCourse); $totalRows_EventListingByCourse = mysql_num_rows($EventListingByCourse); $YI = "SELECT (y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8 + y9) AS yardsIn FROM tbl_courses WHERE courseID = $id"; $YO = "SELECT (y10 + y12 + y13 + y14 + y15 + y16 + y17 + y18) AS yardsOut FROM tbl_courses WHERE courseID = $id"; $yardsIn = mysql_query($YI, $golfscoring); $yardsOut = mysql_query($YO, $golfscoring); $Yin = mysql_fetch_assoc($yardsIn); $Yout = mysql_fetch_assoc($yardsOut); $yardsTotal = $Yin['yardsIn'] + $Yout['yardsOut']; ?> html code here.. blah blah blah.. <?php mysql_free_result($CourseDetail); mysql_free_result($EventListingByCourse); mysql_free_result($totalyards); ?> Can Queries be "pre coded" in mysql like you can in access so the queries don't have to be spelled out in the php file ?
  16. not sure if i should file this under php help or mysql help. i'm building a site with a mysql backend (phpnuke based) and i'm creating a module with a lot of data. / reporting. in the old days, i would have done this in access, but i don't think that down the road the number of connections into the database will be able to support it. what i would have done is a bunh of custom queries in access to manipulate the data, and then just use cases in the code for what i needed to display. this ovbiously is different with mysql. the php side of things is all new to me as well. what's the easiest way to do the queries with php? so far i have come to the conclusion that for every query i do with php, i'll need 5-10 lines of code for each connection and the query structure. is there a way to save the queries in mysql ? any help / tutorials on this would be greatly appreciated. thanks !! ???
  17. here's what i ended up with (golf scoring system...) $YI = "SELECT (y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8 + y9) AS yardsIn FROM tbl_courses WHERE courseID = $id"; $YO = "SELECT (y10 + y12 + y13 + y14 + y15 + y16 + y17 + y18) AS yardsOut FROM tbl_courses WHERE courseID = $id"; $yardsIn = mysql_query($YI, $golfscoring); $yardsOut = mysql_query($YO, $golfscoring); $Yin = mysql_fetch_assoc($yardsIn); $Yout = mysql_fetch_assoc($yardsOut); $yardsTotal = $Yin['yardsIn'] + $Yout['yardsOut']; <?php echo $Yin['yardsIn']; ?> <?php echo $Yout['yardsOut']; ?> <?php echo $yardsTotal; ?> thanks for the help people !
  18. so i tried the following: $sql = "SELECT (y1 + y2) AS yardsTotal FROM tbl_courses WHERE courseID = $id"; $yardstotal = mysql_query($sql, $golfscoring); echo $yardstotal; and got: Resource id #536 sorry, but this is my first time with php and databases, especially mysql.. in the past i've always used coldfusion with access.
  19. i have a table. colums y1,y2,y3,y4 .... i want a total called YardsOut so i can display it on the site: $query_CourseDetail = "select * from tbl_courses WHERE $id = tbl_courses.courseID"; $CourseDetail = mysql_query($query_CourseDetail, $golfscoring) or die(mysql_error()); $row_CourseDetail = mysql_fetch_assoc($CourseDetail); $totalRows_CourseDetail = mysql_num_rows($CourseDetail); $YardsOut = $row_CourseDetail['y1']+$row_CourseDetail['y2']; echo $YardsOut; is there a easier way to get the totals ?
  20. The swf files are in the same directory as the php files that they are going too.
  21. i'm getting control of a domain and going from phtml to php file structure. i basically have everything converted, but i am running into a problem with a video on the site. it doesn't show up !?! i've looked at the code, and everything seems ok. do i have to do something special with shockwave / flash videos with the php code ?? thanks the information / code is pulled from a database, and everything works fine but the video page. here's the code for the header, main video page, and then footer: (i've removed code that doesn't matter) header: session_start(); ?> ... <head> ..... <link type="text/css" rel="stylesheet" href="/global.css" /> <script type="text/javascript" src="/lightbox.js"></script> <script type="text/javascript" src="/swfobject.js"></script> </head> <body> <div id="maincontainer"> <div id="contentwrapper"> <div id="contentcolumn"> <a href="/"><img src="/images/logo.jpg" width="240" height="111" alt="" /><br /> <div id="prinav"> <? if ($section == 'contact') { print "<a href=\"/\"><img src=\"/images/home.jpg\" width=\"165\" height=\"38\" alt=\"\" /></a> <a href=\"/video/\"><img src=\"/images/system_video.jpg\" width=\"165\" height=\"38\" alt=\"\" /></a>"; } elseif ($section == 'video') { print "<a href=\"/\"><img src=\"/images/home.jpg\" width=\"165\" height=\"38\" alt=\"\" /></a> <a href=\"/contact.php\"><img src=\"/images/contact_us.jpg\" width=\"165\" height=\"38\" alt=\"\" /></a>"; } else { print "<a href=\"/video/\"><img src=\"/images/system_video.jpg\" width=\"165\" height=\"38\" alt=\"\" /></a> <a href=\"/contact.php\"><img src=\"/images/contact_us.jpg\" width=\"165\" height=\"38\" alt=\"\" /></a>"; } ?> </div> <div id="mainbody"> videopage: <div id="flashcontent"> <strong>You may need to upgrade your Flash Player to view the Auto-Cut video.<br /><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank">Click here to download the latest version of Adobe Flash Player.</a></strong> </div> <script type="text/javascript"> // <![CDATA[ var so = new SWFObject("/autocut_video.swf", "autocut_video", "420", "350", "6", "#FFFFFF"); so.write("flashcontent"); // ]]> </script> footer: ?> </div> </div> </div> <div id="rightcolumn"> .... </div> <div id="footer"> <p> Copyright © <? print date("Y"); ?> </p> </div> </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.