Welcome Guest, Not a member yet? Register   Sign In
Print pagination help

Hello everyone! Hope you're all well..

Could anyone help me with a little bit of a traditional PHP/logic problem? (my brain is really not working today).

Situation is, I have a client project in CI that prints out load sheets for lorries (they are a delivery firm). I.e. there will be several "delivery runs" a day, then each run will have several deliveries for that day. Traditional nested foreach type thing. There is a view that does this and it is very basic. But I want to try and smarten it up with a pagination/page count e.g. Page 1 of 3 etc.

Put simply, it's like this (code is stripped down completely for simplicity):

<?php foreach ($runs as $run): ?>
  <?php $total_pages = ceil(count($run['deliveries'])/5);?>

  <h1>Runsheet #&lt;?=$run['id']?&gt; (&lt;?=$total_pages?&gt; sheets)</h1>
  Driver name: &lt;?=$run['firstname']?&gt; &lt;?=$run['lastname']?&gt;
  Run totals: &lt;?=$run['totalitems']?&gt; plts at &lt;?=$run['totalweight_kg']?&gt;kg

  &lt;?php $i = 0; ?&gt;
  &lt;?php foreach($run['deliveries'] as $delivery): ?&gt;

    &lt;?php $i++; ?&gt;

    // echo out delivery information here...
    &lt;?php if ($i % 5 == 0) echo '<div style="page-break-after:always;></div>'; ?&gt;
  &lt;?php endforeach; ?&gt;
&lt;?php endforeach; ?&gt;

As you can see I've managed to set it so that only 5 deliveries get shown per page, and it breaks after that. On that basis, I've also used ceil() to work out how many pages there will be if there is 5 deliveries on each.

But I can't for the life of me workout how to set either a header or a footer saying "Page 1 of 3 / Page 2 of 3" and so on through the pages.

Anyone have any ideas to point me in the right direction?

Thanks for your time Smile

Messages In This Thread
Print pagination help - by El Forum - 05-06-2010, 01:13 AM
Print pagination help - by El Forum - 05-06-2010, 09:35 AM
Print pagination help - by El Forum - 05-06-2010, 11:39 AM

Theme © iAndrew 2016 - Forum software by © MyBB