Jump to content

feign3

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

feign3's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a loop creating a list of vendors that have orders placed for their products. The user needs to ability to send each vendor their respective orders so the loop displays a row with the vendor's name and a button that says something like "SEND ORDERS". The table rows are being built with a WHILE loop and I am passing form data elements like the vendor id (main key), vendor email and name from hidden form fields. However, when there are multiple rows/vendors listed on the page and I click the first "SEND EMAIL" button for example, it sends the data elements from the LAST vendor record instead. The closest I got to fixing it was to assign the vendor id to the VALUE of the button but all of the hidden elements still pass the value of the last record on the page. Here is my loop code: <table width="100%" border="0" cellspacing="0" cellpadding="3"> <?php while ($row_GetVendors = mysql_fetch_assoc($GetVendors)){ ?> <tr> <td width="18%"><?php echo $row_GetVendors['vendor_name']; ?></td> <td width="22%">(<?php echo $row_GetVendors['count(oel.vendor_notify_flag)'].' ITEMS TO SEND'; ?>) </td> <td width="60%"><input name="button" type="submit" id="button" value="SEND VENDOR EMAIL"> <input name="vendor_email" type="hidden" value="<?php echo $row_GetVendors['contact_email']; ?>"> <input name="vendor_name" type="hidden" value="<?php echo $row_GetVendors['vendor_name']; ?>"> <input name="vendor_id" type="hidden" value="<?php echo $row_GetVendors['vendor_id']; ?>"> <input type="hidden" name="FormUpdate" value="send_email"> </td> </tr> <tr> <td colspan="3"><img src="/images/blue_spacer.gif" width="100%" height="1"> </tr> <?php } ?> </table> So in the example above, I get 2 rows (one for each vendor that has orders). If I click the first button, it sends all of the values from the second row instead. Here is the generated HTML: <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="18%">Vendor 1 Name</td> <td width="22%">(1 ITEMS TO SEND) </td> <td width="60%"><input name="button" type="submit" id="button" value="SEND VENDOR EMAIL"> <input name="vendor_email" type="hidden" value="craig@email.com"> <input name="vendor_name" type="hidden" value="Vendor 1 Name"> <input name="vendor_id" type="hidden" value="2"> <input type="hidden" name="FormUpdate" value="send_email"> </td> </tr> <tr> <td colspan="3"><img src="/images/blue_spacer.gif" width="100%" height="1"> </tr> <tr> <td width="18%">Vendor 2 Name</td> <td width="22%">(6 ITEMS TO SEND) </td> <td width="60%"><input name="button" type="submit" id="button" value="SEND VENDOR EMAIL"> <input name="vendor_email" type="hidden" value="email@email.com"> <input name="vendor_name" type="hidden" value="Vendor 2 Name"> <input name="vendor_id" type="hidden" value="1"> <input type="hidden" name="FormUpdate" value="send_email"> </td> </tr> <tr> <td colspan="3"><img src="/images/blue_spacer.gif" width="100%" height="1"> </tr> </table> I'm sure this has to do with the way the form works with using multiple submits or something. Does anyone know a good way to do this that still allows me to use submit buttons as opposed to radio buttons and such?
  2. I was able to get a little further with this suggestion however I am having the following problem now. The below code is meant to retrieve some address information for a customer and then get all order details for that customer in an inner loop. while($row = mysql_fetch_assoc($CustomerDetails)) { $body .= "****************************************************************** \n"; $body .= "ORDER # ".$order_count."\n"; $body .= "****************************************************************** \n"; $body .= "NAME: ".$row["title"]." ".$row["first_name"]." ".$row["last_name"]."\n"; $body .= "SHIPPING ADDRESS: ".$row["address_1"]."\n"; $body .= "SHIPPING ADDRESS 2: ".$row_CustomerDetails["address_2"]."\n"; $body .= "CITY: ".$row["city"]."\n"; $body .= "STATE: ".$row["state"]."\n"; $body .= "ZIP: ".$row["zip"]."\n\n"; while ($row_OrderDetails = mysql_fetch_assoc($OrderDetails)){ foreach($row_OrderDetails AS $key) { $body .= "ITEM SKU: ".$key."\n"; $body .= "ITEM NAME: ".$key."\n"; $body .= "QUANTITY: ".$key."\n"; } } } This code however produces the following output: ITEM SKU: 10 ITEM NAME: 10 QUANTITY: 10 ITEM SKU: ANTI-AGING FACIAL SERUM ITEM NAME: ANTI-AGING FACIAL SERUM QUANTITY: ANTI-AGING FACIAL SERUM ITEM SKU: 2 ITEM NAME: 2 QUANTITY: 2 What would be the proper way to do this so I achieve this instead: ITEM SKU: 10 ITEM NAME: ANTI-AGING FACIAL SERUM QUANTITY: 2
  3. Ah! So I would assume that $key is the value I want to pass to the inner loop query... is that correct?
  4. I am having a heck of a time figuring out how to pass a value from a query driving an outer loop to one driving the inner loop in a PHP page like so: while($row = mysql_fetch_assoc($CustomerDetails)) { Pass customer_id from $CustomerDetails query to $OrderDetails in inner loop below while($row = mysql_fetch_assoc($OrderDetails)) { Use customer_id value to drive this inner query } } The two queries are defined farther up in the code but the customer_id value I am trying to use for the second inner loop query seems to be out of scope. Does anyone have any examples of how this might work?
×
×
  • 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.