Jump to content

egiblock

Members
  • Posts

    21
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

egiblock's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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 ?
×
×
  • 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.