Place Order and Multidimensional Arrays

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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


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

Re: Place Order and Multidimensional Arrays

Quoted text here. Click to load it

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.


Re: Place Order and Multidimensional Arrays


This is the section of code:

// Go through each row in the result set
   while ($get_orderguide_items_row =  
mysql_fetch_array($get_orderguide_items_qr, MYSQL_NUM)) {
    $item_id = $get_orderguide_items_row[1];

    // Retrieve item details
    $get_items_q = "SELECT item_id, item_nbr, item_description,  
item_whscode from items where items.item_id = '$item_id'";
    $get_items_qr = @mysql_query($get_items_q) or die(mysql_error());
    $get_items_q_row = mysql_fetch_array($get_items_qr, MYSQL_NUM);


    // Create array item_id, item_unit and item_qty
    $ordeach_line = array ($get_items_q_row[0],  
$get_orderguide_items_row[2], $item_qty);

    $item_block .="
    <td>Last Order</td>
    <td><input type=\"text\" name=\"$ordeach_line[0]\"  
value=\"$ordeach_line[2]\" size=3 maxlength=3></td></tr>";

   } // while each row result set

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

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

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

  } // 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

Re: Place Order and Multidimensional Arrays

Quoted text here. Click to load it
Quoted text here. Click to load it

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.)


Site Timeline