Search the Community
Showing results for tags 'foreach issue'.
-
I have a shopping cart that sends an email once an item is purchased. When an item is added to the shopping cart, if it's a custom item it fills in information into the custom_image if its an custom image item if not it's left blank. All items fill in a custom_product field as well when added to the cart. When I process this script and only have a custom item proccessed or custom product it works perfect. I have the email send an image of the custom images created by the user that's stored in the cart under custom_image. Other products store custom_product information as well. if I have any custom_image product in my cart, it echos that custom image for every product in the cart when processed. If i only have one or the other in the cart it works perfect. From my code I thought if I had a foreach value it would go line by line every time it processed and item and did a check if Image_custom is empty or not. If it's empty then just do the ELSE but it's bleeding over. Any help would be greatly appreciated foreach ($this->get_cart() as $value) { $myurl = "http://www.myurl.com/scripts/"; if (!empty($row['custom_image_10'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> <br>' . $row['custom_product'] . 'x -<a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_4'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_5'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_6'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_7'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_7'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_7'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_8'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_8'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_8'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_9'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_9'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_9'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_10'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_10'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_10'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_9'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> <br>' . $row['custom_product'] . 'x -<a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_4'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_5'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_6'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_7'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_7'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_7'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_8'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_8'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_8'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_9'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_9'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_9'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_8'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_produc'] . 'x -<a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_4'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_5'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_6'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_7'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_7'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_7'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_8'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_8'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_8'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_7'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_4'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_5'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_6'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_7'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_7'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_7'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_6'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_4'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_5'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_6'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_6'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_6'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_5'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_4'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_5'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_5'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_5'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_4'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_4'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_4'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_4'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_3'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_3'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_3'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_3'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image_2'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . '.jpg\" width=\"150\" height=\"100\"></a><br>' . $row['custom_product_2'] . 'x - <a href=\"' . $myurl . '' . $row['custom_image_2'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image_2'] . ".jpg\" width=\"150\" height=\"100\"></a>"; } elseif (!empty($row['custom_image'])) { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . 'x -<a href=\"' . $myurl . '' . $row['custom_image'] . '.jpg\"><img src=\"' . $myurl . '' . $row['custom_image'] . ".jpg\" width=\"150\" height=\"100\"></a><br>"; } else { $products .= $value['product_quantity'] . ' x ' . $value['product_name'] . ' (' . price($value['product_price']) . ') = ' . price($value['total_price']) . ' <br /> ' . $row['custom_product'] . ' ' . $row['custom_product_2'] . ' ' . $row['custom_product_3'] . ' ' . $row['custom_product_4'] . ' ' . $row['custom_product_5'] . ' ' . $row['custom_product_6'] . ' ' . $row['custom_product_7'] . ' ' . $row['custom_product_8'] . ' ' . $row['custom_product_9'] . ' ' . $row['custom_product_10'] . "<br><br>"; }