Jump to content

texmansru47

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by texmansru47

  1. diocyria, I think a need a more detailed example. the form I have is being generated from a table search. //if ($Prod <> 0) { $sql = "SELECT * FROM `OpenBooks` WHERE `bookgrp`= '$group'"; $results = mysql_query($sql); if ($results) { //this will check if the query failed or not if (mysql_num_rows($results) > 0) { //this will check if results were returned while($copy = mysql_fetch_array($results)) { $variable1=$copy['booknum']; $variable2=$copy['bookgrp']; $variable3=$copy['booktitle']; //table layout for results print ("<tr>"); print ("<td><center>$variable1</center></td>"); print ("<td><center>$variable2</center></td>"); print ("<td><left>$variable3</left></td>"); print ("</tr>"); } } else { echo "No results returned"; } } else { echo "Query error: ".mysql_error(); } mysql_close($con); ?> Any ideas how to implement a selection check box in this format?
  2. diocyria - I do beleive that is what I desire. I just need some way to have the user select a value that was generated from a pre-existing table and from that the selected data can be used for adding to another table. On the example code would that create a checkbox that could be added in a IF THEN Loop?
  3. Ok... This is sounding like not the route to go. How about this... Make the list generated from the table be HTML where the user can select and then from there I can create code to do the manipulation of the data from there? I have read somewhere that you can list the data with HTML links... but I need to research that. Cheers,
  4. Hey everyone. I am creating a website so my family can select from the list of present my daugther has asked for. I have them logging in, and that works. I have the table data set and the search and table display works. But I would like to display the list (as in the code below) but with a checkbox in the first column (add a column). From that the authenticated user can click on the item they have purchased and that selection will be moved to another table (called purchased). I have that code. The only thing I cannot figure out is to present the data in list form with a checkbox (like you would see on an order form). Here is the display code (there is no error checking at this point): <head><LINK REL="SHORTCUT ICON" HREF="cmwschl.ico"></head> <body bgcolor="#C0C0C0"> <font face="Arial" color="#000080">Books from the Selected Series</font> </h1> <hr font color="Navy" font size="3"> <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="170" bgcolor="#FFCC66"><center><b><font color="navy" size="2" face="Trebuchet MS"><b><center>Book Number</center></font></b></center></td> <td width="140" bgcolor="#FFCC66"><center><b><font color="navy" size="2" face="Trebuchet MS"><b><center>Book Group</center></font></b></center></td> <td width="100" bgcolor="#FFCC66"><center><b><font color="navy" size="2" face="Trebuchet MS"><b><center>Book Title</center></font></b></center></td> </tr> <?php $con = mysql_connect("localhost","twilson","R00tb33r!") or die('Connection: ' . mysql_error());; mysql_select_db("CMWWeb", $con) or die('Database: ' . mysql_error()); ?> <? $group = $_POST['bookgrp']; //if ($Prod <> 0) { $sql = "SELECT * FROM `OpenBooks` WHERE `bookgrp`= '$group'"; $results = mysql_query($sql); if ($results) { //this will check if the query failed or not if (mysql_num_rows($results) > 0) { //this will check if results were returned while($copy = mysql_fetch_array($results)) { $variable1=$copy['booknum']; $variable2=$copy['bookgrp']; $variable3=$copy['booktitle']; //table layout for results print ("<tr>"); print ("<td><center>$variable1</center></td>"); print ("<td><center>$variable2</center></td>"); print ("<td><left>$variable3</left></td>"); print ("</tr>"); } } else { echo "No results returned"; } } else { echo "Query error: ".mysql_error(); } mysql_close($con); ?> </table> </center>
  5. if so, I still do not get a file prompt to save a file. I get nothing.
  6. You mean the following: $_fp = @fopen( $_file, 'w' ); // should be $_fp = fopen( $_file, 'w' ); @fwrite( $_fp, $_csv_data ); // should be fwrite( $_fp, $_csv_data ); @fclose( $_fp ); // should be fclose( $_fp ); Would that be correct?
  7. All, I have been struggling to create a very simple CSV file (a physical file) from php. I have tried several variations, but here is what I have currently: <?php ini_set('display_errors', 1); error_reporting(E_ALL); $newline = "<br />"; $space =" "; if (isset($_GET['param1']) && !empty($_GET['param1'])){ $BatchNumData=$_GET['param1']; echo "The Batch Number is:\n$BatchNumData and the Shipment is listed as Good.".$newline.$newline; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST'){ $BatchNumData=$_POST['param1']; echo "The Batch Number is:\n$BatchNumData".$newline.$newline; // Connect to mysql database $con = mysql_connect("localhost","user","XXXXXX") or die('Connection: ' . mysql_error());; mysql_select_db("datatest", $con) or die('Database: ' . mysql_error()); //************************************************************ //** Create CSV file for Labeling MP ** //************************************************************ $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; $mpit=$_POST['MPID']; $sql = "SELECT * FROM `ShipTemp` WHERE `BatchNum` = '$BatchNumData' AND `MPBoxNum` = '$mpit'"; $results = mysql_query($sql); $sernumi=$results['serNum']; $model=$results['OEMSku']; $masterid=$results['MPBoxNum']; $_file = 'optlbl1.csv'; $_fp = @fopen( $_file, 'w' ); while (list($sernum,$model,$masterid)=mysql_fetch_row($results)) { $_csv_data=$imei.','.$model.','.$masterid. "\n"; @fwrite( $_fp, $_csv_data ); } @fclose( $_fp ); mysql_close($con); } ?> and I get NOTHING for output. I know I'm missing something, but what? There are NO GOOD tutorials out there and please do not suggest php.net, since I have been all over that and nothing there is clear enough to figure out the root cause of why my codes are not working. Any ideas?
  8. I need the ability to package 36 units into one box... each unit will be tracked by that boxID. For example: If I have product in a table with serial numbers 1 thru 36 let's say, and they all go in one box... and that box ID is 3500... how can I: 1) capture that data in the table where the Product ID and the BOX ID are listed 2) only increment the box number to the next number (incremental) when the box is either: A) reached the limit available which is 36 units. B) the user can terminate the packaging BEFORE 36 if there is not enough items to go into the box? c) Need to have the BOX ID auto generated? Honestly I have tried a one thing to no avail. I have tried: $query = "SELECT MAX(`MPBoxNum`) AS `max` FROM `Ship`"; $findings = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($findings); $startit = $row['max']; // I get a incremental value for each item under box ID (1, then 2, etc). I could have the user insert the BOX ID when they are shipping, but that would be REAL time consuming and a real pain since they would have to know all last BOX ID or run a query to find it. Any ideas?
  9. Well I thought I had the proper logic (and I may) but I cannot see to figure out why it is not working: Scenario: I have a form that has php code behind it. When the user enters in the data there is a check that has to be made: 1) has the product been processed as "ALL GOOD" (that is where the product is ok, and was passed to shipping) 2) If the product was not ALL GOOD did it PASSED, if so enter a particular type of data for that record in the production and history tables. 3) if the product was not ALL GOOD and it FAILED, if so enter a particular amount of data in the production and history tables (see code below) The problem is if I flag data that is in the database as "All GOOD" the proper response occurs (I get the error message from the isset() statement being positive) but if the product I enter in is either PASSED or FAILED, nothing happens. I thought using a IF ELSEIF statement would be the proper validation point but either it is not or my INSERT code is all wrong. I have tried the INSERT code for the PASSED portion without any IF ELSE or IF ELSEIF statement and it wrote the proper date to the table, so I think it is correct. I'm just not sure why it is not working. Here is the code: <?php if (isset($_GET['param1']) && !empty($_GET['param1'])){ $prod=$_GET['param1']; echo "Your Prod Number is:\n$prod"; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST'){ $imei=$_POST['param1']; echo "Your Bloody prod Number is:\n$prod"; // Main PHP code for connecting to the database for production processing $con = mysql_connect("localhost","user","xxxxxx") or die('Connection: ' . mysql_error());; mysql_select_db("logdata", $con) or die('Database: ' . mysql_error()); //Initial search and selection. $grabit = "SELECT * FROM `recv` WHERE `ProdNum` = '$prod'"; $testdata = mysql_query($grabit) or die(mysql_error()); $testit = mysql_fetch_assoc($testdata) or die(mysql_error()); //SQL query for is the Prod Number was completed fine, this will populate the PROD table accordingly. // variables for this section only! $ota =$_POST['TestResults']; $notes=$_POST['undernotes']; // variables from the SELECT Query $batch=$testit['BatchNum']; $sku=$testit['ModelSku']; $type=$testit['ModelType']; $serial=$testit['SerNum']; $card=$testit['CardType']; //Run the Select Query to gather the proper FailCode response from Table FailCode (Lookup Table) to populate the Prod/ProdHist Tables. $failcode = "SELECT * FROM `FailCode` WHERE `CodeID` = '$codeid'"; $faildata = mysql_query($failcode) or die(mysql_error()); $failrun = mysql_fetch_assoc($faildata) or die(mysql_error()); //Set variable from Fail Code SELECT process. $failit=$failrun['FailCode']; $failnotes=$_POST['FailNotes']; //Search the Prod Database for duplicates $findit = "SELECT * FROM `Prod` WHERE `ProdNum` = '$prod'"; $finddata = mysql_query($findit) or die(mysql_error()); $dataresults = mysql_fetch_assoc($finddata) or die(mysql_error()); // variables from the verification of AllGOOD Query $done=$dataresults['PassGood']; // Test loop of the data inputted to verify the data inputted into the table. if (isset($done) == 'Yes') { ?> <head> <script language="JavaScript"> alert("This Unit has been passed as ALL GOOD. Please forward to Kitting."); </script> </head> <?php } elseif ($ota == 'Passed'){ // INSERT Data into Prod Table. @mysql_query("INSERT INTO `Prod` (`BatchNum`,`ProdNum`,`SerNum`,`ModelSku`,`ModelType`,`CardType`,`TestResults`,`undernotes`,`DateRep`) VALUES ('$batch', '$prod','$serial','$sku','$type','$card','$ota','$notes', Now())") or die(mysql_error()); @mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); //Insert this record into the SnaProd Database for historical purposes. mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `IMEINum` = '$prod'") or die(mysql_error()); //Notifies the User that the record was successfully inputted into the Prod Table. print "<p>This record was updated in the History Table.</p>"; } else { // INSERT Data into Prod Table. @mysql_query("INSERT INTO `Prod` (`BatchNum`,`ProdNum`,`SerNum`,`ModelSku`,`ModelType`,`CardType`,`TestResults`,`undernotes`,`DateRep`) VALUES ('$batch', '$prod','$serial','$sku','$type','$card','$ota','$notes', Now())") or die(mysql_error()); @mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); //Insert this record into the Prod Database for historical purposes. mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `ProdNum` = '$prod'") or die(mysql_error()); //Notifies the User that the record was successfully inputted into the Prod Table. print "<p>This record was recorded as a FAILURE in the History Table.</p>"; mysql_close($con); } ?> The form is here: <!-- This section will create the form for the "Repair" Unit popup window. --> <form method="post" name="prod" action="repair.php"><font color="#000080" face="Arial"> <input type="hidden" name="param1" value="<?php echo $imei; ?>" /> <p><u><b><font size="2" font color="maroon" font type="Tahoma">Repair Section:</font></b></u></p> <p><font face="Arial" font size="2"> <b>OTA Pass/Fail: <select name="TestResults" size="1" name="TestResults"> <option value="NULL">--</option> <option value="Passed">Passed</option> <option value="Failed">Failed</option> </select></b></font> <font face="Arial" font size="2"><br> <b>Fail Code(If Failed): <select name="CodeID" size="1" name="CodeID"> <option value="0">No Fail</option> <option value="1">No Power</option> <option value="2">Not Recognized</option> <option value="3">No Connection</option> <option value="4">Unable to Boot</option> <option value="5">WLAN Fail</option> </select></b></font> <font face="Arial" font size="2"><br> <td <font color="Navy" size="3" face="Tahoma"><b>Fail (Other): </b></font></td> <td><input name="FailNotes" type="text" id="FailNotes" size="35"><br> <td <font color="Black" size="2" face="Tahoma">Notes: </font></td> <td><input name="undernotes" type="text" id="undernotes" size="35"> <p align="center"> <!-- <input type="submit" value="Repair Data Submit" name="submit"></p> --> <input type="submit" value="Repair Data Submit" name="submit" onclick="refresh_page();window.close()"></p> </td> </body> </form> <form method="post"> <input type="button" value="Close Window" onclick="window.close()"> </form> To recap: I get the proper response if the input is in the database is marked as ALL GOOD, but I cannot write data if the unit is not ALL GOOD and PASSED or FAILED. Any ideas?
  10. Well I got the error message to work the problem is I had to take on the following command to see it: <input type="submit" value="Repair Data Submit" name="submit" onclick="window.close()"></p> Is there a way to have the error message pop up when the submit button is click, but also shutdown window as well... like a time delay or something? Here the code again: <?php if (isset($_GET['param1']) && !empty($_GET['param1'])){ $imei=$_GET['param1']; echo "Your Prod Number is:\n$prod"; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST'){ $imei=$_POST['param1']; // echo "Your Bloody Prod Number is:\n$prod"; // Main PHP code for connecting to the database for production processing $con = mysql_connect("localhost","user","xxxxxxx") or die('Connection: ' . mysql_error());; mysql_select_db("logdata", $con) or die('Database: ' . mysql_error()); //Initial search and selection. $grabit = "SELECT * FROM `Prod` WHERE `ProdNum` = '$prod"; $testdata = mysql_query($grabit) or die(mysql_error()); $testit = mysql_fetch_assoc($testdata) or die(mysql_error()); //SQL query for is the Prod Num was completed fine, this will populate the PROD table accordingly. // This query is to generate values for validation. echo "\nThere is a Completed Transaction for this Record in this table."; // variables from the SELECT Query $done=$testit['PassGood']; $batch=$testit['BatchNum']; $sku=$testit['ModelSku']; $type=$testit['ModelType']; $rts=$testit['RTSNum']; $card=$testit['CardType']; $notes=$_POST['undernotes']; // variables for this section only! $qc =$_POST['qcstatus']; $Diag = 'Passed'; $ota =$_POST['TestResults']; // Test loop of the data inputted to verify the data inputted into the table. if (isset($done)) { ?> <head> <script language="JavaScript"> alert("This Unit has been passed as ALL GOOD. Please forward to Kitting."); </script> </head> <?php } else { mysql_query("INSERT INTO `Prod` (`BatchNum`,`ProdNum`,`ModelNum`,`Diagnostic`,`ModelSku`,`ModelType`,`CardType`,`TestResults`,`undernotes`,`DateRep`) VALUES ('$batch', '$prod','$modnum','$Diag','$sku','$type','$card','$ota','$notes', Now())") or die(mysql_error()); @mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `IMEINum` = '$prod'") or die(mysql_error()); // Notify the User that the record is being copied to the ProdHist Table. print "<p>This record was updated in the History Table.</p>"; mysql_close($con); } } ?> <body> <P> <!-- This section will create the form for the "Repair" Unit popup window. --> <form method="post" name="prod" action="repair.php"><font color="#000080" face="Arial"> <input type="hidden" name="param1" value="<?php echo $prod; ?>" /> <p><u><b><font size="2" font color="maroon" font type="Tahoma">Under 30 Repair OTA Section:</font></b></u></p> <p><font face="Arial" font size="2"> <b>OTA Pass/Fail: <select name="TestResults" size="1" name="TestResults"> <option value="NULL">--</option> <option value="Passed">Passed</option> <option value="Failed">Failed</option> </select></b></font> <font face="Arial" font size="2"> <td <font color="Navy" size="3" face="Tahoma"><b><u>Notes:</u> </b></font></td> <td><input name="undernotes" type="text" id="undernotes" size="35"> <p align="center"> <input type="submit" value="Repair Data Submit" name="submit"></p> </td> </body> </form> I desire the popup form to be closed when the user clicks submit, but the error message to popup even if the form is closed... OR Have the error message popup when the SUBMIT button is clicked and when the OK button on the error message is clicked both the form and message go away. The only problem is what if the user enters in a value that is not in the table and the ELSE option kicks in. Currently, without the onclick=windows.close() function, the form remains. If I put the function back in the error message and form disappear so the user has no idea what transpired. I guess I would like my cake and eat it too! Any ideas what I'm doing wrong? thanks,
  11. I have a javascript popup as an error in a php if (isset verification). I cannot tell whether or not the loop is working incorrectly or the popup is just not being called. from the code it appears to be working (the if (isset verification)) since the work I ask to be completed if the response from the if (isset) loop is false, then write the record into the proper table and that is not happening. So is there someone out there who can verify my javascript for the popup is correct or provide a means of validating my code in a test I would be grateful. Here is the code: <?php if (isset($_GET['param1']) && !empty($_GET['param1'])){ $prod=$_GET['param1']; echo "Your Prod Number is:\n$prod"; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST'){ $imei=$_POST['param1']; echo "Your Bloody Prod Number is:\n$prod"; // Main PHP code for connecting to the database for production processing $con = mysql_connect("localhost","user","xxxxxx") or die('Connection: ' . mysql_error());; mysql_select_db("logdata", $con) or die('Database: ' . mysql_error()); //SQL query for is the Prod Num was completed fine, this will populate the PROD table accordingly. // This query is to generate values for validation. $grabit = "SELECT * FROM `Prod` WHERE `ProdNum` = '$prod"; $testdata = mysql_query($grabit) or die(mysql_error()); $testit = mysql_fetch_assoc($testdata) or die(mysql_error()); print_r('$testit'); ?? I get nothing from this command - It may be due to when I click submit the form is scheduled to close, and the information is not displayed. // variables from the SELECT Query $done=$testit['PassGood']; $batch=$testit['BatchNum']; $sku=$testit['ModelSku']; $type=$testit['ModelType']; $model=$testit['ModelNum']; $card=$testit['CardType']; $notes=$_POST['undernotes']; // variables for this section only! $qc =$_POST['qcstatus']; $Diag = 'Passed'; $ota =$_POST['TestResults']; // Test loop of the data inputted to verify the data inputted into the table. This is where I try to validate if a record for that Prod Num exists or not - not getting the error message at all. if (isset($done)) { ?> <head> <script language="JavaScript"> alert("This Unit has been passed as ALL GOOD. Please forward to Kitting."); </script> </head> <?php } else { mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `ProdNum` = '$prod") or die(mysql_error()); //but this portion of the code is not working when I put in a Prod Number that is already in the table. // Notify the User that the record is being copied to the ProdHist Table. print "<p>This record was updated in the History Table.</p>"; // Insert the new data for this record in the main Prod Table. This code is also not working when there is a duplicate record in the table. mysql_query("UPDATE `Prod` Set `Diagnositc` = '$Diag' Set `TestResults` = '$ota' Set `undernotes` = '$notes' Set `DateRep` = Now() WHERE `ProdNum` = '$prod'") or die(mysql_error()); @mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); mysql_close($con); } } ?> <body bgcolor="#CCCCCC"> <P> <BODY OnLoad="placeFocus()"> <!-- This section will create the form for the "all Good" Unit popup window. --> <form method="post" name="prod" action="repair.php"><font color="#000080" face="Arial"> <input type="hidden" name="param1" value="<?php echo $imei; ?>" /> <p><u><b><font size="2" font color="maroon" font type="Tahoma">Repair Section:</font></b></u></p> <p><font face="Arial" font size="2"> <b>OTA Pass/Fail: <select name="TestResults" size="1" name="TestResults"> <option value="NULL">--</option> <option value="Passed">Passed</option> <option value="Failed">Failed</option> </select></b></font> <font face="Arial" font size="2"> <td <font color="Navy" size="3" face="Tahoma"><b><u>Notes:</u> </b></font></td> <td><input name="undernotes" type="text" id="undernotes" size="35"> <p align="center"> <input type="submit" value="Repair Data Submit" name="submit" onclick="window.close()"></p> </form> So when I have a duplicate Prod Num the php code seems to be working... there is no INSERT or UPDATE being processed. I will be testing more on the results of a unique Prod Number being entered as well.
  12. gee thanks for pointing me in the right direction.
  13. I have seen a couple of these questions asked before but I cannot remember if there was ever an answer: I need to incorporate a barcode scanner for my forms in data entry... I have seen a few responses that we should use javascripts... but where can I find some reference material on javascripting for barcode scanners? Primarily for incorporating a tab to the next field without the standard carriage return being processed... and to get the submit button to work once I get the scanne to tab down to the next field. Any ideas?
  14. I have seen a couple of these questions asked before but I cannot remember if there was ever an answer: I need to incorporate a barcode scanner for my forms in data entry... I have seen a few responses that we should use javascripts... but where can I find some reference material on javascripting for barcode scanners? Primarily for incorporating a <Tab> instead of a <ENTER> when a field is scanned and/OR how to get the barcode cursor move to the next field if there is no way to set the <ENTER> function of the scanner to a <TAB>. Any ideas?
  15. Sader, I guess I do not understand.... The variable I have set is: $Qty=$sql[Qty]... it seems to work since I get a value when I run the print_r($sql) command. unkwntech: That field will be for data inputting into the database from the users... I thought that cannot be auto increment.... is that a wrong assessment?
  16. I have been working on this page for now three weeks, and everytime I get something to work something else breaks. Here is what I'm trying to do: 1) Pass a variable from the parent form to a popup form (working) 2) Use that passed variable to process a SELECT * query from table 1 - (working) 3) On the second form (the popup spawned from the parent form) the user has to enter in two pieces of information (ProdNum and SerNum). 4) then I run a INSERT query to input some of the data from table 1 (from the SELECT Query I ran) as well as the two $_POST variables the user just entered (ProdNum and SerNum) 5) I run this in a loop using a counter that increments by one each pass agains the QTY value of the Batch that these products are being entered into the database for. Here has been my problems: 1) At first when I pass the variable from the parent form to the popup entry form a "ghost record" was entered (no data from the user input - only the data from the SELECT query... this happens as soon as the form is presented... the user has no time to process anything, not even pressing the SUBMIT button. I tired the !isset() function to no avail... at all... never worked once. So I added a DELETE query to remove any records with the ProdNum set as '0'. Seems to work. 2) The queries all work... the SELECT, the INSERT and the DELETE when I put in a straight value instead of the value of the passed variable (instead of a variable I set to equal the passed variable I put in a number like '1') everything works... data is written to the database appropriately, and the counter works... the only problem is I get the following error: where '4294967295' is any number you enter... and there are no duplicates at all... regardless the number entered... this error occurs, but the data is written to the database properly. 3) If I add the the variable that was passed to the second popup form the INSERT query does not input any data into the table while I have the DELETE query active. But if you run a print_r against the SELECT query all the data is pulling correctly... I have also inputted a few echo command to list the values of particular fields being SELECTED and they are all there. If I deactive the DELETE query only the initial blank record I mentioned earlier is inputted into the table and no other record I try to enter is. Here is the code I have for the popup where it seems all the problems are: <?php $BatchNumData=$_GET['param1']; echo "Your Batch Number is:\n$BatchNumData"; // Connect to mysql database $con = mysql_connect("localhost","user","xxxx") or die('Connection: ' . mysql_error());; mysql_select_db("snatest", $con) or die('Database: ' . mysql_error()); // Insert form values into database $sql = mysql_fetch_array(mysql_query("SELECT * FROM `batch` WHERE `BatchNum`= '$BatchNumData'")) or die(mysql_error()); // ^^ SELECT THE DATA TO BE COPIED ^^ $Batch=$sql['BatchNum']; $Qty=$sql[Qty]; $RTSNum=$sql['1Num']; $ModelType=$sql['ModelType']; $Sku=$sql['Sku']; $Card=$sql['Card']; $growit = 1; while ($growit <= $Qty) { @mysql_query("INSERT INTO `recv` (`BatchNum`, `ProdNum`, `SerNum`, `ModelType`, `ModelSku`, `1Num`,`Card`, `DateRecv`) VALUES ('$Batch', '" . $_POST['ProdNum'] . "', '" . $_POST['SerNum'] . "','$ModelType','$Sku','$RTSNum', '$Card', Now())") or die(mysql_error()); @mysql_query("DELETE FROM `recv` WHERE `ProdNum` = 0"); $growit = $growit + 1; } echo "<br>Your QTY is:\n $Qty"; mysql_close($con); ?> Now I'm trying to solves these problems but I cannot seem to figure out where to start. On the database here are the vitals: The Primary Key is the ProdNum No Auto Increment Class = BigInt[15] Must be Unique Not sure if that helps. At this point I cannot move forward since I really do not know what to do. I would love to get the !isset() function to work but it is just not. BTW - the popup form portion of this page is on the top part of the php page where this above listed code is located: Here is the form coding: <form method="post" name="Recv" action="entry.php"><font color="#000080" face="Arial"> <table border="0" cellpadding="3" cellspacing="2" width="400"> <tbody> <tr style="color: rgb(255, 255, 255); font-weight: bold;"> <td colspan="2" bgcolor="#000000"><span class="style1">Receiving Module</span></td> </tr> <tr> <td bgcolor="#ffcc66">Serial Number: </td> <td bgcolor="#cccccc"><input name="SerNum" id="SerNum" type="text"></td> </tr> <tr> <td bgcolor="#ffcc66" width="135">Prod Number:</td> <td bgcolor="#cccccc" width="300"><input name="ProdNum" id="ProdNum" type="text"></td> </tr> <tr> <td> </td> <td><input value="submit" name="submit" type="submit"></td> </tr> </tbody> </table> Honestly I'm a newbie to development and my hat is off to you all who can figure this stuff out. I have a trial by fire since I am an owner of this company with 20 years Infrastructure background... no development, so if anyone out there could throw me a bone I would greatly appreciate it. Thanks,
  17. Yes I did... The form comes up and I can enter data, but nothing is written to the database. Before that IF statement, the data from the SELECT query is put in, but the $_POST inputs are still not working.
  18. So you are indicating that my form should work now... without changing anything?
  19. Here is what I got: <html> <head> <title>Receiving - Part Two</title> </head> <body bgcolor="#C0C0C0"> <b><img border="0" src="logo1.jpg" width="45" height="44"> <font face="Arial" color="#000080">Product Entry</font></b><font face="Arial" color="#000080"> <hr> <P> <form method="POST" name="Recv" action="entry.php"> <table width="400" border="0" cellspacing="2" cellpadding="3"> <tr> <td colspan="2" bgcolor="#000000"><span class="style1">Receiving</span></td> </tr> <tr> <td bgcolor="#FFCC66">Serial Number: </td> <td bgcolor="#CCCCCC"><input name="SerNum" type="text" id="SerNum"></td> </tr> <tr> <td width="135" bgcolor="#FFCC66">Asset Number:</td> <td width="300" bgcolor="#CCCCCC"><input name="ProdNum" type="text" id="ProdNum"></td> </tr> <tr> <td> </td> <td><input type="submit" value="submit" name="submit" /></td> </tr> </table> </form> <?php if (isset($_POST['submit'])) { $BatchNumData=$_GET['param1']; echo "Your Batch Number is:\n$BatchNumData"; // Connect to mysql database $con = mysql_connect("localhost","user","xxxxx") or die('Connection: ' . mysql_error());; mysql_select_db("test", $con) or die('Database: ' . mysql_error()); // Insert form values into database $copy = mysql_fetch_array(mysql_query("SELECT * FROM `batch` WHERE `BatchNum`= '$BatchNumData'")) or die(mysql_error()); // ^^ SELECT THE DATA TO BE COPIED ^^ @mysql_query("INSERT INTO `recv` (`BatchNum`, `1Num`, `SerNum`, `ProdNum`, `ModelSku`, `ModelType`, `DateRecv`) VALUES ('" . $copy['BatchNum'] . "', '" . $copy['RTSNum'] . "', '" . $_POST[serNum] ."', '" . $_POST[ProdNum] ."', '". $copy['Sku'] ."', '". $copy['ModelType'] ."', Now())") or die(mysql_error()); mysql_close($con); } ?> </body> </html> Without your additional code (the if statement) I get a blank record in my database of "0" value for the ProdNum and a blank for the SerNum but I get the proper value of from the SELECT command and INSERT (the $copy variables). I don't understand why this form is processing without any interaction from me. This code is the code from the parent form that calls this popup (javascript involved): <head> <title>Receiving</title> </head> <body bgcolor="#CCCCCC"> <b><img border="0" src="logo1.jpg" width="78" height="77"> <font face="Arial" color="#000080">Receiving - Part One</font></b><font face="Arial" color="#000080"> <P> <form method="POST" name="Recv" action="recvbatch.php"> <table width="550" border="0" cellspacing="2" cellpadding="3"> <tr> <td colspan="2" bgcolor="#000000"><span class="style1">Batch/RA Receiving Start</span></td> </tr> <tr> <td bgcolor="#FFCC66">RA Number: </td> <td bgcolor="#CCCCCC"><input name="BatchNum" type="text" id="BatchNum"></td> </tr> <tr> <td> </td> <td><input type="submit" value="Submit Batch Request" /></td> </tr> </table> </form> </body> <center> <hr> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="140" align="center"><b>RA Number</b></td> <td width="130" align="center"><b>Prod Number</b></td> <td width="75" align="center"><b>KU</b></td> <td width="140" align="center"><b>Type of Repair</b></td> <td width="140" align="center"><b>Model</b></td> <td width="60" align="center"><b>Qty</b></td> <td width="140" align="center"><b>Model Type</b></td> <td width="130" align="center"><b>Received Date</b></td> </tr> <?php error_reporting(E_ERROR | E_WARNING | E_PARSE); $con = mysql_connect("localhost","users","xxxx") or die('Connection: ' . mysql_error());; mysql_select_db("test", $con) or die('Database: ' . mysql_error()); ?><? $sql = "SELECT * FROM `batch` WHERE `BatchNum`= '$_POST[batchNum]'"; $results = mysql_query($sql); if ($results) { //this will check if the query failed or not if (mysql_num_rows($results) > 0) { //this will check if results were returned while($copy = mysql_fetch_array($results)) { $variable1=$copy['BatchNum']; $variable2=$copy['1Num']; $variable3=$copy['Sku']; $variable4=$copy['Type']; $variable5=$copy['Model']; $variable6=$copy['Qty']; $variable7=$copy['ModelID']; $variable8=$copy['RecvDate']; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("<td>$variable5</td>"); print ("<td>$variable6</td>"); print ("<td>$variable7</td>"); print ("<td>$variable8</td>"); print ("</tr>"); } } else { echo "No results returned"; } } else { echo "Query error: ".mysql_error(); } $batch1 = $variable1; mysql_close($con); ?> </table> <script language="JavaScript" type="Text/JavaScript"> //Will call the popup Window for Product Entry. var fifteenth;var sixteenth;var seventeenth; function eighteenth(nineteenth,twentieth) { seventeenth=eval("document.getElementById('"+nineteenth+"')");sixteenth=twentieth;fifteenth=seventeenth.childNodes[0].nodeValue;seventeenth.childNodes[0].nodeValue=twentieth;} function first2() { seventeenth.childNodes[0].nodeValue=fifteenth;} </script> </center> <center> <script> <!-- function openpopup(url, windowtarget) { window.open( url, windowtarget, 'width=570,height=290,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0'); } // --> </script> <a href="entry.php?param1=<?php echo $batch1; ?>" target="entry" OnClick="openpopup(this.href, 'entry'); return false;">Entry Screen</a> </center> <p><a href="receiving.html">Return to Main Receiving Page</a></p> I hope this helps, Texman
  20. Yes I did. So I believe I have a form that is not working correctly. Any suggestions as to where I should start to look for solutions?
  21. Well I placed it just after the <? php start call and the final } bracket before the ?> tag. Not nothing is being added to my database. I take it that this is working then?
  22. just to make sure what you are saying is for: if (isset($_POST['submit'])) { //Your code here } I would place that before my sql queries and INSERT?
  23. OK... How would I do that? Again, I'm new to this and I have not come across this yet. Texman
  24. Do you mean the single '? I read that somewhere to do that... not sure why. I'm self teaching myself php so I gather my data from tutorials, books and and these forums. I see what the problem seems to be is that when the popup is opened, I get a record in my database without even typing in data. Anyone had a cure for that? Sound even crazier than my first question. But it seems when the popup entry form is opened, it generates a record... with blanks for my two values required.
×
×
  • 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.