Place Order and Multidimensional Arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Brown

    Place Order and Multidimensional Arrays

    Hello,

    The problem I am having is this:

    I would like an array to have three fields

    (item_id, item_unit, item_qty) - this I can do from prior postings.

    Now the Order entry form is something like

    Line # ITEM # ITEM DESCRIPTION ITEM UNIT ITEM QTY.

    I create the string to put in the form - only ITEM QTY is an input text.
    The rest have been pulled from the database.

    As I loop through the mysql query I populate the three fields in the
    array - obviously item_qty is 0 at this point as it has not been submitted.

    I don't know what to put for the input type=\"text\" line using the
    array I have created so on submit item_qty has been populated and ready
    to be processed so the array fields can be put in an order table.

    So on submit the array looks like

    (1234, CS, 3)
    (5678, EA, 2) and so on...

    Using a print within the submit conditional I see

    1234 CS 0 - the zero does not change no matter what I enter for ITEM QTY.

    Any help/pointers much appreciated,

    Peter Brown

  • Steve

    #2
    Re: Place Order and Multidimensiona l Arrays

    [color=blue]
    > The problem I am having is this:[/color]

    Could be any number of things. Please post actual code that minimally
    demonstrates the problem. You may find that preparing this example will
    expose the problem but if not, post it.

    ---
    Steve

    Comment

    • Peter Brown

      #3
      Re: Place Order and Multidimensiona l Arrays

      Hello,

      This is the section of code:

      // Go through each row in the result set
      while ($get_orderguid e_items_row =
      mysql_fetch_arr ay($get_ordergu ide_items_qr, MYSQL_NUM)) {
      $item_id = $get_orderguide _items_row[1];

      // Retrieve item details
      $get_items_q = "SELECT item_id, item_nbr, item_descriptio n,
      item_whscode from items where items.item_id = '$item_id'";
      $get_items_qr = @mysql_query($g et_items_q) or die(mysql_error ());
      $get_items_q_ro w = mysql_fetch_arr ay($get_items_q r, MYSQL_NUM);

      $item_line++;

      // Create array item_id, item_unit and item_qty
      $ordeach_line = array ($get_items_q_r ow[0],
      $get_orderguide _items_row[2], $item_qty);

      $item_block .="
      <tr><td>$item_l ine</td>
      <td>$get_items_ q_row[1]</td>
      <td>$get_items_ q_row[2]</td>
      <td>Last Order</td>
      <td>$ordeach_li ne[1]</td>
      <td><input type=\"text\" name=\"$ordeach _line[0]\"
      value=\"$ordeac h_line[2]\" size=3 maxlength=3></td></tr>";

      } // while each row result set

      } else {
      $message .= "<p>No Order Guide found for $get_customer_i d_row[1]</p>";
      } // else


      if (isset($_POST['submit'])) { //Handle the form


      print "<p> Order is $ordeach_line[0] $ordeach_line[1]
      $ordeach_line[2]</p>";


      } // Main isset submit conditional


      Again the print within 'submit' does not record anything when I put a
      value in the input box.

      Thank you,

      Peter Brown

      Comment

      • Steve

        #4
        Re: Place Order and Multidimensiona l Arrays

        [color=blue]
        > This is the section of code:[/color]
        --snip--[color=blue]
        > $ordeach_line =
        > array ($get_items_q_r ow[0], $get_orderguide _items_row[2], $item_qty);[/color]
        --snip--


        Variable $item_qty has not been explicity set to any value, are you
        assuming it will be set from the submitted form? This doesn't happen by
        default on any new installation of PHP.

        To get the form variable you need to look in the $_POST array ie
        $_POST['item_qty'] (assuming your form uses method="POST"; use the
        $_GET array otherwise.)

        ---
        Steve

        Comment

        Working...