Welcome Guest, Not a member yet? Register   Sign In
Simple Looping Problem
#1
Question 

Hi,

I'm running into a little bit of trouble and would appriciate some guidance.

I currently have a list of statuses held in a database table called 'status'. These are 'Open', 'Closed', 'Pending'.

I also have another table of sales which is in a table called 'sales'.

I'm trying to loop around each status and get the relevant sales, but am having a bit of an issue working out how this is done.

Please note the below code does not work  Undecided

Controller:

PHP Code:
// this returns all the statuses (open, closed, pending)
$data["status"] = $this->sales_model->get_status();

// now i want to loop around these and get the all the items with the that status_id
foreach($data['status'] as $status){
 
   $data["sales"] = $this->sales_model->get_all($status['status_id']);


View:

PHP Code:
<?php foreach ($status as $s){ ?>
    <!-- loop around and get each status -->
    <h1>$s['status_title'];</h1>
    
    <!-- now i want to loop around the results and display them for this status -->
    <?php print_r($sales); ?>

<?php }else{ ?>
    <!-- no status found -->
   <p>Sorry no status found</p>
<?php ?>

Thank you for your time.

MoFish
Reply


Messages In This Thread
Simple Looping Problem - by MoFish - 12-13-2014, 07:59 AM
RE: Simple Looping Problem - by wolfgang1983 - 12-13-2014, 08:09 AM
RE: Simple Looping Problem - by MoFish - 12-13-2014, 08:58 AM
RE: Simple Looping Problem - by includebeer - 12-13-2014, 03:11 PM
RE: Simple Looping Problem - by MoFish - 12-13-2014, 03:44 PM
RE: Simple Looping Problem - by includebeer - 12-13-2014, 05:45 PM
RE: Simple Looping Problem - by MoFish - 12-14-2014, 04:52 AM
RE: Simple Looping Problem - by includebeer - 12-14-2014, 05:22 AM
RE: Simple Looping Problem - by MoFish - 12-14-2014, 05:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB