Jump to content
Larry Ullman's Book Forums

ROY2

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ROY2

  • Rank
    Newbie
  1. Hi, I am trying to get this code to work, and can't figure out what I'm not doing correctly. New to javascript, PHP and HTML. My PHP code below is not working. I select records from some data base files and store all of the records in an array. I display the information from the first record on the screen. When the "Next" button on the screen is clicked, I want to read the array and get the next record and display that information on the screen. The user will continue to hit the "Next" button until all the records have been displayed on the screen for review. I've tried to do this various ways and just cannot get it to work, and this is my latest version. I didn't know how to get the $item_array code to work within the javascript code.So now I am trying to test the VAR mytest from the javascript. Do I need to use AJAX to pass it or is there a better way? Or how do I get the code to work in javascript? Any help would be appreciated!! Regards, Roy My array definition: $item_array = array(); Sample data from array: [10009] => Array ( [iTEM] => 10009) [10063] => Array ( [iTEM] => 10063) [10066] => Array ( [iTEM] => 10066) Loading the array from the file: $item_array[$item] = $row; When the "Next" button on screen is clicked, I execute a javascript function, passing a value of 1.The javascript code is executed and mytest = 1 My html code: <input type="button" class="button" value="Next Item" onclick="javascript:setval(1)" /> My script: <script> var mytest = ''; function setval(varval) { mytest= varval; } </script> In PHP code, I'm testing if mytest = 1, then <?php $mytest = mytest; if (mytest == '1') { foreach ($item_array as $key => $value) { $itemkey = $key; echo $itemkey; } } ?>
  2. Thank you so much! I used your suggestion # 1 and it is working. Roy
  3. Larry, First time poster. Just starting out with PHP, finding your PHP for the Web:Visual QuisckStart Guide exactly what I need to help me understand how to do PHP. I plan to purchase your advanced version of PHP and SQL as soon as I finish this book. I have written an inquiry program with one page for the header and another for the detail. When a link for the line item on the first page is clicked, I pass the order# associated with that line item via the URL to the second page as a $_GET. On the second page, I use a $_GET for the order# and use that order# in my SQL statement. This works fine, it brings up all the detail lines associated with that header order#. However, I have a drop down selection on that second screen where the user can select to display only a certain status type. After the page has been displayed the first time, if they make a selection and then press a reload button on that screen, the order# is now blank and the query fails. I have a session_start; at the very beginning of the 2nd screen. This is my $_GET stmt: $ordernbr = $_GET["ordernbr"]; This is my query select stmt: $query_stmt = "SELECT * FROM MYLIB/SOMEFILE where f1dsorn = $ordernbr"; This is my reload statement: <input type="submit" class="button" value="Reload"> I have an echo of the $ordernbr, and when the Reload button is pressed the value becomes null. Does anyone have any suggestions how to save the $ordernbr when the reload button is pressed? Thanks in advance. Roy
×
×
  • Create New...