Jump to content

jwilliams

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by jwilliams

  1. Okay guys, thanks for all of your help...I've figured it out...it was a problem with my form. It was a careless overlook...my checkbox field was receiving the wrong value.. instead of receiving the $checkedItems value it was receiving the $myItems value. When i fixed this, the correct number of rows are inserted every time with the correct data! Thank you for all of your help!
  2. Make sure you select a CLIENT from the drop down in step 1 first... Select DVTIME STUDIOS...then the GENERATE INVOICES button will appear
  3. Okay, go to this page to see the form and the code: http://www.drs-flash.com/drs/intranet/add_invoices10.php user:  test pass: test In STEP 1, select DV TIME STUDIOS In STEP 2, press the Generate Invoice Button In STEP 3, click the blue carrot next to DV Time Studios to drill down Select some items, and then press Add to Invoice Thanks Josiah
  4. It's not letting me paste rest of code...i will post a preview online.
  5. So as you can see, there is a link to a javascript function within that form, here is the code pulled out for your reference: [code] <a href="javascript:showItems('<?php echo $myID; ?>','<?php echo $row_selectProjects['projectID'] ; ?>', '<?php echo $uniqueID; ?>');"><img src="images/carrot.gif" width="10" height="15" border="0"></a> [/code] and here is the showItems() function [code] function showItems(myID, itemID, rowID){ location.href  = 'add_invoices10.php?recordID='+myID+'&itemID='+itemID+'&rowID='+rowID+'&step=3'; } [/code]
  6. Okay, the form gets a bit confusing because i'm generating it on the fly with Javascript DOM, but I will post to see if you guys can make heads or tails of it. So here is the main form, that lists all projects associated with a client, currently there is a checkbox next to each project (this is not the checkbox i'm having trouble with). This form lists projects...if you press a button within this form, it drills down and lists all ITEMS associated with that project.  This is all done dynamically with javascript.  PHP passes values to my javascript function, which then generates a row for each item and lists the items under each project.  Next to each item is a check box, these are the checkboxes i'm having problems with.  If you check several boxes and hit submit, it grabs the correct values for the checkbox and the $myItems, but for nothing else.  I will start by posting the main projects form here: [code] <form action="<?php echo $editFormAction; ?>" method="POST" name="projects">   <table id="myTable" width="775" border="0" align="center" cellpadding="0" cellspacing="0">   <tr class="columnHeaders">   <td width="25">&nbsp;</td>   <td width="250">project</td>   <td width="300">description</td>   <td width="75">hours</td>   <td width="75">rate</td>   <td width="150">total</td>   </tr> <?php #alternate row colors $current_row = 0; $uniqueID = 0; do { $current_row = 1 - $current_row; $uniqueID++; ?>     <tr id="row<?php echo $row_selectProjects['projectID']; ?>" class="row<?php echo $current_row; ?>">   <td><input name="projects" type="checkbox" value="1">   <input name="myRowID" type="hidden" id="row<?php echo $row_selectProjects['projectID']; ?>" value="row<?php echo $row_selectProjects['projectID']; ?>"><input name="projectID" type="hidden" value="<?php echo $row_selectProjects['projectID']; ?>"></td>       <td height="25"><a href="javascript:showItems('<?php echo $myID; ?>','<?php echo $row_selectProjects['projectID'] ; ?>', '<?php echo $uniqueID; ?>');"><img src="images/carrot.gif" width="10" height="15" border="0"></a><?php echo $row_selectProjects['project_name']; ?></td>       <td><?php echo $row_selectProjects['project_desc']; ?></td>       <td><?php echo $row_selectProjects['total_hours_converted']; ?></td>       <td><?php echo $row_selectProjects['billable_rate']; ?></td>       <td>$<?php echo $row_selectProjects['total_billable']; ?></td>     </tr> <?php $cellID = $row_selectItems['itemID'] ; ?> <?php } while ($row_selectProjects = mysql_fetch_assoc($selectProjects)); ?> <tr> <td colspan="6"><img src="images/horz_line.gif" width="100%" height="7"> </td> </tr> <tr> <td colspan="6"><input name="clientID" type="hidden" value="<?php echo $myID; ?>"> <input name="invoiceID" type="hidden" value="<?php echo $myInsertID; ?>">   <input name="myDate" type="hidden" value="<?php echo $myDate; ?>"> <input name="" type="submit" value="Add to Invoice"> </td> </tr> </table>   <input type="hidden" name="MM_insert" value="projects"> </form> [/code]
  7. or it could be that now all 20 items from each array is being inserted into the database instead of just the items i've checked.
  8. I just realized that my checkedItems array is iterating backwards... so where myRow[0]::checkedItems[19] could this be my problem?
  9. So as you can see...after it properly selects myItems, it then adds these next indexes into the database: Example of array data entered into database (from myHours array) [code] <?php Array (     [0] => 0.02     [1] => 0.62     [2] => 1.99     [3] => 0.66 ) ?> [/code] So it's not properly selecting the index from checkedItems, rather iterating through $key, which starts at zero. Any idea how to fix this? Thanks again
  10. Thanks so much for your help on this....I think we are ALMOST there. I implemented what you suggested, and here are my results: I checked the following items on my form: [code] <?php Array - myItems (     [14] => 28     [16] => 26     [18] => 21     [19] => 22 ) Array - myChildren (         [14] => 26     [16] => 0     [18] => 0     [19] => 0 ) Array - myHours (         [14] => 1.14     [16] => 1.15     [18] => 2.00     [19] => 1.00 ) Array - myRate (       [14] => 100     [16] => 100     [18] => 100     [19] => 100 ) ?> However, the following information went into my database: <?php Array - myItems - ALL DATA CORRECT (     [14] => 28     [16] => 26     [18] => 21     [19] => 22 ) Array - myChildren - DATA INCORRECT (         [14] => 0  --- should be 26     [16] => 0     [18] => 0     [19] => 0 ) Array - myHours (         [14] => .02 -- should be 1.14     [16] => .62 -- should be 1.15     [18] => 1.99 -- should be 2.00     [19] => .66 -- should be 1.00 ) Array - myRate (       [14] => 100     [16] => 100     [18] => 100     [19] => 100 ) ?> [/code] So what i don't understand is why the myItems value is being carried over correctly and the rest are not??
  11. Yes, the arrays are passed from the form. myItems[] is the array of all checkboxes that are checked myRate, myChildren and myHours are all hidden fields residing in the same row as the checkbox, and are made into arrays as well. Thank you for checking back frequently!
  12. Okay, they are...in this order... myItems, myChildren, myHours, myRate [code] <?php Array (     [0] => 42     [1] => 41     [2] => 40     [3] => 39     [4] => 38     [5] => 37     [6] => 36     [7] => 35     [8] => 34     [9] => 33     [10] => 32     [11] => 31     [12] => 30     [13] => 29     [14] => 28     [15] => 27     [16] => 26     [17] => 25     [18] => 21     [19] => 22 ) Array (     [0] => 0     [1] => 0     [2] => 0     [3] => 0     [4] => 0     [5] => 0     [6] => 0     [7] => 0     [8] => 0     [9] => 0     [10] => 0     [11] => 0     [12] => 25     [13] => 26     [14] => 26     [15] => 26     [16] => 0     [17] => 0     [18] => 0     [19] => 0 ) Array (     [0] => 0.02     [1] => 0.62     [2] => 1.99     [3] => 0.66     [4] => 1.02     [5] => 0.34     [6] => 0.04     [7] => 0.08     [8] => 0.02     [9] => 0.08     [10] => 0.03     [11] => 9.02     [12] => 0.68     [13] => 0.79     [14] => 1.14     [15] => 1.25     [16] => 1.15     [17] => 1.00     [18] => 2.00     [19] => 1.00 ) Array (     [0] => 100     [1] => 100     [2] => 100     [3] => 100     [4] => 100     [5] => 100     [6] => 100     [7] => 100     [8] => 100     [9] => 100     [10] => 100     [11] => 100     [12] => 100     [13] => 100     [14] => 100     [15] => 100     [16] => 100     [17] => 100     [18] => 100     [19] => 100 ) ?> [/code] If I insert all of these arrays everything works fine...but if I select only a few in the middle (based on check boxes from a form) and then try to insert just those items, all of the correct $myItems come through, but the others iterate from 0, and the data doesn't match up. What can you make of this? Thanks for your help! Josiah
  13. Okay, here's what I'm trying to do... I'm trying to insert multiple arrays into the same mysql table at once.  That works fine using foreach()...but only inserts the correct data for the array listed as the parameter in the foreach() loop. The other arrays get inserted, but with incorrect data, like the proper index for the array isn't being assigned or something... Here is my code: [code] <?php $myChildren = $_POST["myChildren"]; $myHours = $_POST["myHours"];         $myRate = $_POST["myRate"]; ##for each instance in our items array (checked items)...insert a new record foreach($_POST["myItems"] AS $key => $myItems){   $insertSQL = sprintf("INSERT INTO drs_invoices_items (invoiceID, itemID, childID, hours_logged, billable_rate) VALUES (%s, '$myItems', '$myChildren[$key]', '{$_POST["myHours"][$key]}', '{$_POST["myRate"][$key]}')", #used for invoiceID   GetSQLValueString($_POST['invoiceID'], "int"));                 mysql_select_db($database_drs_database, $drs_database);               $Result1 = mysql_query($insertSQL, $drs_database) or die(mysql_error());               } ?> [/code] So the proper number of rows are inserted based on the $myItems array... But the other arrays ($myChildren, $myHours, $myRate), all get populated with data from other idexes in the array, and not from the same array index as $myItems is pulled from. I've been trying everything, to no avail. I don't think I know enough about this stuff... Can somebody please help me? Thanks much in advance. Josiah
  14. Hey Ray, Was wondering if you got the chance to peek at the link i provided?
  15. Hi, I posted a preview online for you to see... here is the link:  http://www.drs-flash.com/drs/intranet/add_invoices.php?recordID=8&itemID=15 user: test pass: test Thanks for all of your help!
  16. hi again, my second query (selectItems), which only gets called if $itemID exists in the URL, does reference the project id in the where close as noted below from selectItems query: [code]WHERE drs_time_tracker.projectID = $itemID"; [/code] The selectItems query is passed the projectID through the URL as referenced by itemID All the data is pulling properly based on this, it's just putting it in the wrong row! See images above.
  17. belay my last, $myID references clientID...i will try your suggestion and post my results. thanks
  18. sorry for my ambiguity, $myID is a reference to projectID
  19. no this is a private site on my local intranet. I can post screenshots or answer any questions you may have.  my current host isn't using mysql 4.0 so i can't upload online for a preview for you. Will this deter us in troubleshooting? Regarding your last post, both the selectItems and selectProjects query call to projectId in the where clause.
  20. oops, forgot to post, here they are: [code] <?php mysql_select_db($database_drs_database, $drs_database); $query_selectClients = "SELECT drs_time_tracker.clientID, drs_clients.client_name AS client_name FROM drs_time_tracker, drs_clients WHERE drs_time_tracker.clientID = drs_clients.clientID GROUP by clientID ORDER by client_name"; $selectClients = mysql_query($query_selectClients, $drs_database) or die(mysql_error()); $row_selectClients = mysql_fetch_assoc($selectClients); $totalRows_selectClients = mysql_num_rows($selectClients); $itemID = $_GET['itemID']; $colname_selectItems = "-1"; if (isset($_GET['itemID'])) {     $colname_selectItems = (get_magic_quotes_gpc()) ? $_GET['itemID'] : addslashes($_GET['itemID']); $query_selectItems = "SELECT drs_time_tracker.itemID, drs_time_tracker.childID, drs_time_tracker.projectID, drs_time_tracker.item_date, drs_time_tracker.item_details, drs_time_tracker.billable_rate, TIME_FORMAT(SEC_TO_TIME(TIME_TO_SEC(drs_time_tracker.out_time) - TIME_TO_SEC(drs_time_tracker.in_time)), '%H:%i') AS total_hours, ROUND(((((TIME_TO_SEC(TIME_FORMAT(drs_time_tracker.out_time, '%H:%i')) - TIME_TO_SEC(TIME_FORMAT(drs_time_tracker.in_time, '%H:%i'))) / 60) / 60 ) * drs_time_tracker.billable_rate), 2) AS 'total_billable'  FROM drs_time_tracker WHERE drs_time_tracker.projectID = $itemID"; $selectItems = mysql_query($query_selectItems, $drs_database) or die(mysql_error()); $row_selectItems = mysql_fetch_assoc($selectItems); $totalRows_selectItems = mysql_num_rows($selectItems); } #grab our variable from the url #if(isset($_GET['recordID'])){ $myID = $_GET['recordID']; $colname_selectProjects = "-1"; if (isset($_GET['recordID'])) {     $colname_selectProjects = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']); mysql_select_db($database_drs_database, $drs_database); $query_selectProjects = "SELECT drs_time_tracker.itemID, drs_time_tracker.childID, drs_time_tracker.projectID, drs_projects.project_name AS project_name, drs_clients.client_name AS client_name, drs_time_tracker.item_date, LEFT(drs_time_tracker.item_details, 25) AS short_details, LEFT(drs_projects.project_desc, 40) AS project_desc, drs_time_tracker.in_time, drs_time_tracker.out_time, TIME_FORMAT(SEC_TO_TIME(TIME_TO_SEC(drs_time_tracker.out_time) - TIME_TO_SEC(drs_time_tracker.in_time)), '%H:%i') AS total_hours,  drs_time_tracker.hours_logged, drs_time_tracker.hours_converted, drs_time_tracker.billable_rate, drs_time_tracker.item_total, drs_time_tracker.invoiced, SUM(ROUND((((TIME_TO_SEC(drs_time_tracker.out_time) - TIME_TO_SEC(drs_time_tracker.in_time)) / 60) /60), 2)) AS 'total_hours_converted', SUM(ROUND(((((TIME_TO_SEC(TIME_FORMAT(out_time, '%H:%i')) - TIME_TO_SEC(TIME_FORMAT(in_time, '%H:%i'))) / 60) / 60 ) * billable_rate), 2)) AS 'total_billable' FROM drs_time_tracker, drs_projects, drs_clients WHERE drs_time_tracker.projectID = drs_projects.projectID AND drs_time_tracker.clientID = drs_clients.clientID AND drs_time_tracker.clientID = $myID GROUP BY drs_time_tracker.projectID ORDER BY drs_time_tracker.item_date DESC"; $query_selectProjects . "TIME_FORMAT(SEC_TO_TIME(TIME_TO_SEC(drs_time_tracker.out_time) - TIME_TO_SEC(drs_time_tracker.in_time)), '%H:%i') AS total_hours"; $query_selectProjects . "SET @total_hours = TIME_FORMAT(SEC_TO_TIME(TIME_TO_SEC(drs_time_tracker.out_time) - TIME_TO_SEC(drs_time_tracker.in_time)), '%H:%i')"; $query_selectProjects . "SET @total_billable = SUM(ROUND(((((TIME_TO_SEC(TIME_FORMAT(out_time, '%H:%i')) - TIME_TO_SEC(TIME_FORMAT(in_time, '%H:%i'))) / 60) / 60 ) * billable_rate), 2)) AS 'total_billable"; $selectProjects = mysql_query($query_selectProjects, $drs_database) or die(mysql_error()); $row_selectProjects = mysql_fetch_assoc($selectProjects); $totalRows_selectProjects = mysql_num_rows($selectProjects); } ?> [/code]
  21. Using three queries, 'selectClients', 'selectProjects' and 'selectItems', I am building a detail set.  In the first step, you select a client, which then lists all projects for that client. In the second step, I wish to have the user drill down the project to see all items associated with that project.  I can output the queries without any problem, the problem lies in where the output is going, and I think it has something to do with my looping.  When you drill down a project, it lists the proper items for that project, but it always lists them under the very first project, not the project you clicked on.  I will post my code in hopes someone can steer me in the correct direction...i've been racking my brain over this for days.  I'm only listing the problematic code, where you see all projects associated with a client and can drill down to see project details (items). [code] <table width="775" border="0" align="center" cellpadding="0" cellspacing="0">     <tr class="columnHeaders">       <td width="25">&nbsp;</td>   <td width="250">project</td>       <td width="300">description</td>       <td width="75">hours</td>       <td width="75">rate</td>       <td width="150">total</td>     </tr> <?php #alternate row colors $current_row = 0; do { $current_row = 1 - $current_row; ?>     <tr class="row<?php echo $current_row; ?>">   <td><input name="items" type="checkbox" value=""></td>       <td height="25"><a href="javascript:showItems('<?php echo $myID; ?>','<?php echo $row_selectProjects['projectID']; ?>');"><img src="images/carrot.gif" width="10" height="15" border="0"></a><?php echo $row_selectProjects['project_name']; ?></td>       <td><?php echo $row_selectProjects['project_desc']; ?></td>       <td><?php echo $row_selectProjects['total_hours_converted']; ?></td>       <td><?php echo $row_selectProjects['billable_rate']; ?></td>       <td>$<?php echo $row_selectProjects['total_billable']; ?></td>     </tr> <?php $item_row = 0; do { $item_row = 1 - $item_row; ?> <form name="ten" action="" method="post">     <tr class="item_row<?php echo $item_row; ?>">   <td><input name="test" type="text" value="hi" size="5" id="nine"></td>       <td height="25"><img src="images/small_arrow.gif" width="24" height="12"><?php echo $row_selectItems['item_date']; ?></td>       <td><?php echo $row_selectItems['item_details']; ?></td>       <td><?php echo $row_selectItems['total_hours']; ?></td>       <td><?php echo $row_selectItems['billable_rate']; ?></td>   <td><?php echo $row_selectItems['total_billable']; ?></td>           </tr> <?php } while ($row_selectItems = mysql_fetch_assoc($selectItems)); ?> </form> <?php } while ($row_selectProjects = mysql_fetch_assoc($selectProjects)); ?> </table> [/code] And here are some screenshots for your reference. Here is a screen shot of Project 003 being drilled down to show ITEMS under Project 003 [img]http://www.drs-flash.com/drs/project003.jpg[/img] And here is a screenshot of Project 001 being drilled down.  Notice that Project 001 items appear under Project 003 rather than Project 001. [img]http://www.drs-flash.com/drs/project001.jpg[/img] if you need to see more code please let me know, and thanks in advance for your help.
×
×
  • 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.