Jump to content

ShadowFire

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by ShadowFire

  1. Haha! Wow that was definitely a miss on my part. So, you're saying I need the quotes.. =) Thank you!
  2. Thank you! I actually just caught that before I read your reply, and went ahead and tossed in two zeros for the null values. Perhaps you can help me with what happened after that was fixed: echoed insert: INSERT INTO pendingordersdetails (PartNumber,Oqty,Pqty,Aqty,PartStatus, PartPrice,idOrderNo,PrtTariffCode,PrtLocation,LineNum,PKqty,SPqty,AllocationDate) VALUES ('0446535240 ',3,0,1,'Excess',163.89,66,' ', 'A0406E01',2,0,0,2012-01-24) error: Incorrect date value: '1987' for column 'AllocationDate' at row 1 This one is really bizarre.. since I can see the date value being inserted, and the date value is definitely not '1987' (though that probably was a pretty good year).
  3. I'm having trouble inserting a formatted PHP DateTime into a MySQL table. I'm getting: 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 ',2012-01-31)' at line 4 I get the error when I try to insert the date as a string from a DateTime object via: $insertDate = $date->format('Y-m-d'); As well as when I try to recast it as a date object: $insertDate = date("Y-m-d",strtotime($date->format('Y-m-d'))); I've also tried putting the date in ' ' 's and escaped " " 's. My insert query is: $insert = "INSERT INTO pendingordersdetails (PartNumber,Oqty,Pqty,Aqty,PartStatus, PartPrice,idOrderNo,PrtTariffCode,PrtLocation,LineNum,PKqty,SPqty,AllocationDate) VALUES ('$partNum',$oQty,0,$aQty,'Excess',$price,$orderNum,'$tariffCode', '$location',$lineNum,$PKqty,$SPqty,'$allocDate');"; and the echoed output is: INSERT INTO pendingordersdetails (PartNumber,Oqty,Pqty,Aqty,PartStatus, PartPrice,idOrderNo,PrtTariffCode,PrtLocation,LineNum,PKqty,SPqty,AllocationDate) VALUES ('0446535240 ',3,0,1,'Excess',163.89,66,' ', 'A0406E01',2,,,'2012-01-31'); Anyone have any ideas?
  4. Update: I figured out how to do this. I'm not sure if it's the absolute cleanest solution, but essentially I was unable to get the form to send only the rows which were checked on submit. But, in addition to all of the form data being sent the value field for any checked row will send. In the value field I serialized a PHP variable and then unserialize it on the other end (when the page refreshes). Then, for any indexes that were stored in the data for the rows I sent, I update their entries in the table. Since, the table data is now current (post-updates), I can safely read the values from the database to display any updated data in the form. I think the cleanest solution would be one in which the input boxes of only rows which have been checked when apply changes is clicked, are sent (rather than needing to check each row against the values of the PHP object I serialized). But, for now this should do.
  5. I want the data to update in the form (in the input boxes if the checkbox is checked). I also want any changes to be updated in the database (but I know how to do that). I just need to know how to get the data for a whole row to send if the checkbox to the left of that row is checked when the "Apply Changes" button is clicked. Here's what I have right now: <?php for($i=0; $order = mysql_fetch_array($orderResults);$i++ ) { ?> <table border="1" bgcolor="white"> <thead> <tr> <th>Dealer ID</th> </tr> </thead> <tbody> <tr> <td><?php echo $order["DealerID"];?></td> </tr> </tbody> </table> <table title="Pending Orders" width="90%" align="center"> <!-- <thead> <tr><th colspan="2" align="center">Dealer ID</th><th align="center"><?php echo $order["DealerID"]; ?></th></tr> <tr bgcolor="#CCCCCC">--> <th></th> <th>Part No.</th> <th>Order Quantity</th> <th>Allocated Quantity</th> <th>Pending Quantity</th> <th>Order Type</th> </tr> </thead> <form name="updateQty" action="PendingOrder.php" method="GET"> <?php //. htmlspecialchars(serialize($partArray[$k]), ENT_QUOTES) . $partDetailsResults = mysql_query("SELECT * FROM pendingordersdetails WHERE idOrderNo = '$orderID';"); for($j = 0; $part = mysql_fetch_array($partDetailsResults); $j++) { $k = $i + $j; $partArray[$k]["Oqty"] = $part["Oqty"]; $partArray[$k]["Aqty"] = $part["Aqty"]; $partArray[$k]["Pqty"] = $part["Pqty"]; if($part["PartStatus"] == "Regular") { ?><tr id="reg"><?php } else if($part["PartStatus"] == "Excess") { ?><tr id="exc"><?php } else //$part["PartStatus"] == "Abnormal" { ?><tr id="abn"><?php } echo "<td><input type=\"checkbox\" name=\"applyChanges[]\" value=\"" . htmlspecialchars(serialize($partArray[$k]), ENT_QUOTES) . "\"> </td> <td>" . $part["PartNumber"] . "</td>";?> <td><input type="text" name="Oqty" onchange="" value="<?php echo $part["Oqty"]; ?>" /></td> <td><input type="text" name="Aqty" value="<?php echo $part["Aqty"]; ?>" /></td> <td><input type="text" name="Pqty" value="<?php echo $part["Pqty"]; ?>" /></td> <?php if($part["PartStatus"] == "Regular") echo ""; else if ($part["PartStatus"] == "Excess") echo ""; else echo ""; if($part["PartStatus"] == "Regular") { ?> <td> <select> <option id="regular" value="Regular">Regular</option> <option id="excess" value="Excess">Excess</option> <option id="abnormal" value="Abnormal">Abnormal</option> </select> </td> </tr> <?php } else if ($part["PartStatus"] == "Excess") { ?> <td> <select> <option id="regular" value="Regular">Regular</option> <option id="excess" selected ="selected" value="Excess">Excess</option></font> <option id="abnormal" value="Abnormal">Abnormal</option> </select> </td> </tr> <?php } else //$part["Otype"] == "Abnormal" { ?> <td> <select> <option id="Regular">Regular</option> <option id="Excess">Excess</option> <option selected ="selected" id="Abnormal">Abnormal</option> </select> </td> </tr> <?php } } } ?> <tr><td colspan="5"></td> <td align="right"><?php echo "<input type=\"hidden\" name=\"OrderID\" value=\"$orderID\">"; ?> <input type="submit" name="updateQty" value="Apply Changes" /> </td> </tr> </tbody> </table> MOD EDIT: . . . BBCode tags added.
  6. I've been poking around online for about a day now trying to find a good way to do the following: I have an "order" I'm reading in from a MySQL database (not completely relevant, but just fyi). And, for this order there are a number of "parts" (automotive parts) that have been ordered. For each part there is data pertaining to the quantity of parts that have been ordered and the number of parts that have been allocated (based on our inventory) and then a third column that has the number of parts still in that order that are still to be allocated at a future date. Basically, I'm displaying this data in a form with each row having a checkbox to the far left. What I want to do is allow the user to check any number of check boxes. If a check box is checked the form should submit all of the input text boxes for that row (the user can update the quantities) that I talked about in the second paragraph for that "part" (each part is displayed in a row and has a checkbox). Unfortunately, most of the examples I found for checkboxes in a form submit a specific value (like a number of a letter). I need the form to submit the values that are in the textboxes. So basically, I'm thinking I need the page to update a PHP object whenever the value of a textbox is changed and then when the user clicks a button it will send the php object for each checked row through GET or POST. But, how would I get it to onchange update a PHP object (the PHP object would need to be a 2-D array where the first index allows you to select the part and the second index allows you to select which quantity you will change). I'm thinking I would need to call a script from the onchange like: onchange="somePHPfunction(partNumberIndex, whichQuantityI'mChanging, currentValueOfThatQuantity)" but of course that would require me to embed some php inside the onchange call since the partNumberIndex and whichQuantity are PHP variables.. Any ideas on how to do this sort of thing? Or any ideas on how to do this differently? I'm trying to avoid javascript because it would place a javascript constraint on the users. But, maybe there's no other way to do this sort of thing? Any help would be greatly appreciated!
×
×
  • 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.