jamesxg1 Posted November 7, 2010 Share Posted November 7, 2010 Hiya! I have an issue, here is my code. <?php class generateInvoice { private $invoiceID; public function __construct($invoiceID) { $this->_INID = mysql_real_escape_string($invoiceID); } public function __drawInvoice() { $get_invoice = "SELECT * FROM `invoices` WHERE `id` = '$this->_INID' LIMIT 1"; $run_get_invoice = mysql_query($get_invoice); if($run_get_invoice) { if(mysql_num_rows($run_get_invoice) == 1) { while($invoice_m = mysql_fetch_assoc($run_get_invoice)) { if($invoice_m == 1) { $status = 'Awaiting Payment'; } elseif($invoice_m == 2) { $status = 'Paid'; } $items_mass = explode(',', $invoice_m['items']); foreach($items_mass as $item_key => $item_value) { $item_split = explode('-', $item_value); echo '<pre>' . print_r($item_split, true) . '</pre>'; foreach($item_split as $item_key_final => $item_value_final) { $invoice .= ' <tr class="item-row"> <td class="item-name"><div class="delete-wpr">' . $item_value_final[1] . '</div></td> <td class="description">THIS IS THE DESCRIPTION</td> <td><span class="cost">$650.00</span></td> <td><span class="qty">1</span></td> <td><span class="price">$650.00</span></td> </tr>'; } } } return $invoice; } else { return false; } } else { return false; } } } ?> This is what is displayed. Array ( [0] => 1 [1] => Test Product [2] => 6.99 [3] => 2 ) Array ( [0] => 5 [1] => Tester Product [2] => 600.99 [3] => 1 ) THIS IS THE DESCRIPTION $650.00 1 $650.00 e THIS IS THE DESCRIPTION $650.00 1 $650.00 . THIS IS THE DESCRIPTION $650.00 1 $650.00 THIS IS THE DESCRIPTION $650.00 1 $650.00 THIS IS THE DESCRIPTION $650.00 1 $650.00 e THIS IS THE DESCRIPTION $650.00 1 $650.00 0 THIS IS THE DESCRIPTION $650.00 1 $650.00 THIS IS THE DESCRIPTION $650.00 1 $650.00 I need it so that I can use each of the array's above and echo out each item (key) individually. I don't understand whats going wrong? Many thanks, James. Link to comment https://forums.phpfreaks.com/topic/218003-foreach-loop-problem-please-help/ Share on other sites More sharing options...
jamesxg1 Posted November 7, 2010 Author Share Posted November 7, 2010 Any have any ideas? Any help will be much appreciated. Many thanks, James. Link to comment https://forums.phpfreaks.com/topic/218003-foreach-loop-problem-please-help/#findComment-1131371 Share on other sites More sharing options...
jamesxg1 Posted November 7, 2010 Author Share Posted November 7, 2010 Does anyone have any ideas? I really need some help here. Many thanks, James. Link to comment https://forums.phpfreaks.com/topic/218003-foreach-loop-problem-please-help/#findComment-1131416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.