Problem in Duplication of data and onenter key

newphpcoder

Verified User
Joined
Dec 22, 2010
Messages
7
Good day!


I have 2 problems with my code 1st is in the last operation name or the 04 Oper it was duplicate but the duplicate was only the operation name and the rest data was blank . I tried to debug it but I ca'n find where is wrong in my syntax. And the 2nd problem is for the enter key function or array, because my textbox I used array, and to move on the next textbox i used enter key, the problem is on the last date when i press enter key instead of move the cursor on the shift textbox it was save. I want to happen is after the last date and I press enter key the cursor was on the shift textbox then after i input data in shift and i press enter key it will save.


Here is my code:


PHP:
<?php
 if($rexist == 0)
                        {
                        $query = "SELECT t.operation_name, t.input_unit, t.output_unit FROM trace_operations t WHERE t.plt_typeno = '" . $_POST["plt_typeno"] . "'  AND t.operation_name IN('02 Oper','03 Oper','04 Oper') ORDER BY t.operation_name";
                      
                        $last_operation_name = "";
                        $result = mysql_query($query);
                        if($result){
                        $totalrows = mysql_num_rows($result);
                        $trows = $totalrows - 1;
                          for($ctr = 0; $ctr < $trows; $ctr++)
                           {
                          $row = mysql_fetch_array($result);
                          $tctr = $ctr + 1;
                           echo "\n\t<tr>";
                           echo "\n\t\t<td width='800'>";
                           if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];
                            $last_operation_name = $row["operation_name"];
                            echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>";   
                            echo "\n\t\t<td><input size='6' type='text' name='timein[]' id='timein" . $ctr . "' onkeypress='return handleEnter(event,\"timeout" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='timeout[]' id='timeout" . $ctr . "' onkeypress='return handleEnter(event,\"inqty" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='inqty[]' id='inqty" . $ctr . "' onkeypress='return handleEnter(event,\"outqty" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td>" . $row["input_unit"];
                            echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' onkeypress='return handleEnter(event,\"idno" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td>" . $row["output_unit"];
                            echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='idno[]' id='idno" . $ctr . "' onkeypress='return handleEnter(event,\"mcno" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='mcno[]' id='mcno" . $ctr . "' onkeypress='return handleEnter(event,\"varqty" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='varqty[]' id='varqty" . $ctr . "' onkeypress='return handleEnter(event,\"varplt" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='varplt[]' id='varplt" . $ctr . "' onkeypress='return handleEnter(event,\"dateshift" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='dateshift[]' id='dateshift" . $ctr . "' onkeypress='return handleEnter(event,\"shift" . $ctr . "\");' /></td>";
                           echo "\n\t\t<td><input size='6' type='text' name='shift[]' id='shift" . $ctr . "' onkeypress='return handleEnter(event,\"timein" . $tctr . "\");' /></td>";
                            echo "\n\t</tr>";
                            }
                       if($totalrows > 1);
                            {
                            $row = mysql_fetch_array($result);
                            echo "\n\t<tr>";
                            echo "\n\t\t<td width='800'>";
                            if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];
                            $last_operation_name = $row["operation_name"];
                            echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>";   
                            echo "<input type='hidden' name='opname[]' value='" . $row["operation_name"] . "' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='timein[]' id='timein" . $ctr . "' onkeypress='return handleEnter(event,\"timeout" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='timeout[]' id='timeout" . $ctr . "' onkeypress='return handleEnter(event,\"inqty" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='inqty[]' id='inqty" . $ctr . "' onkeypress='return handleEnter(event,\"outqty" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td>" . $row["input_unit"];
                            echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' onkeypress='return handleEnter(event,\"idno" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td>" . $row["output_unit"];
                            echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='idno[]' id='idno" . $ctr . "' onkeypress='return handleEnter(event,\"mcno" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='mcno[]' id='mcno" . $ctr . "' onkeypress='return handleEnter(event,\"varqty" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='varqty[]' id='varqty" . $ctr . "' onkeypress='return handleEnter(event,\"varplt" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='varplt[]' id='varplt" . $ctr . "' onkeypress='return handleEnter(event,\"dateshift" . $ctr . "\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='dateshift[]' id='dateshift" . $ctr . "' onkeypress='return handleEnter(event,\"shift\");' /></td>";
                            echo "\n\t\t<td><input size='6' type='text' name='shift[]' id='shift" . $ctr . "' onkeypress='return handleEnter(event,\"saveform\");' /></td>";
                            echo "\n\t</tr>";
                            }
                        echo "</table>";
                        echo "<p><input type='submit' value='Save' id='saveform' /></p>";
                        echo "<input type='hidden' name='plt_typeno' value='" . $_POST["plt_typeno"] . "' />";
                        }  
                        }  
?>


Any help is highly appreciated..

Thank you very much.. Ask me a question if my problem did not clear with you.:confused:


Again, Thank you so much
 
Hi newphpcoder. I can't see any problem from the code that you make. Maybe I just overlooked or there's a syntax error. I'll check the code later and I'll see how I can help you.
 
Back
Top