Help with pagination

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
Hi, got a prob. My code works great except that it only displays 1 line. Please advise.
----------------------------------------------------------------------------------------
the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head><body><center>
<div class="display print">

<?php error_reporting (E_ALL ^ E_NOTICE);

// Include config file
require_once "getprerentdb.php";

//MySqli Select Query
$results = $mysqli->query("SELECT * FROM payfile");//Print version
//Set at what record to break at 25 records per page
$BreakAT=25;
$num=0;
$pagenum = 1;
$totpaid=0;
// ---------------------------------------
while($row = mysqli_fetch_array($results)) {
// ----------------------------------------
if($num % $BreakAT == 0)
{
if($num>0)

{ echo '</table class="print">';
echo '<div class="breakhere"></div>';
$pagenum++; }

echo date('m/d/y');
echo " Page " . $pagenum;
?>
<div class="title">Payment Report</div><br />
<table align="center" cellspacing=0 cellpadding=0 border=1>
<thead>
<tr>
<th>tenant</th>
<th>unit</th>
<th>rent paid</th>
<th>rent due</th>
<th>due date</th>
<th>prev bal</th>
<th>late chg</th>
<th>sec dep</th>
<th>damage</th>
<th>court cost</th>
<th>nsf</th>
<th>hud pay</th>
<th>tenant pay</th>
<th>date paid</th>
<th align=left>comment</th>
</tr>
</thead>
<?php
$totpaid += $row['paidsum'];
echo '
<tr>
<td>' . $row['tenant'] . '</td>
<td>' . $row['unit'] . '</td>
<td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td>
<td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
<td>' . $row['duedate'] . '</td>
<td align=right class="currency">$'.number_format($row['prevbal'],2).'</td>
<td align=right class="currency">$'.number_format($row['latechg'],2).'</td>
<td align=right class="currency">$'.number_format($row['secdep'],2).'</td>
<td align=right class="currency">$'.number_format($row['damage'],2).'</td>
<td align=right class="currency">$'.number_format($row['courtcost'],2).'</td>
<td align=right class="currency">$'.number_format($row['nsf'],2).'</td>
<td align=right class="currency">$'.number_format($row['hudpay'],2).'</td>
<td align=right class="currency">$'.number_format($row['paidsum'],2).'</td>
<td>' . $row['datepaid'] . '</td>
<td>' . $row['comments'] . '</td>
</tr>';
$num++;
}
}
echo '
<tr>
<th scope="row" colspan="12">Total Paid:</th>
<td bgcolor="#FFD4D4" class="currency">' . number_format($totpaid, 2, '.', '') . '</td>
</tr>
</table>';

?>
</center></div></body></html>
 

Xsage

Dave
Joined
Jan 8, 2016
Messages
343
You seem to be missing a closing bracket on your if statement/it is in the wrong place. Below is a super simplified version of your code. In your code, the echo's that produce the records are where the uncommented "echo $num . "\r\n";" is. This code returns one record and it is record 0.
PHP:
<?php
$BreakAT=25;
$pagenum = 1;


for ($num = 0; $num <= 200; $num++) {
   
    if($num % $BreakAT == 0){
        if($num>0){
         $pagenum++;
         return;
        }
        echo $num . "\r\n";
    }
    //echo $num . "\r\n";
}
?>
If in the above code, you swap the comments so that the echo is one level higher and forms part of the "if($num % $BreakAT == 0)" statement, it returns 25 records there so I believe that is where you have gone wrong.

I'm not sure how you are going to handle the actual pagination though but you could do something like this:

PHP:
<?php
    $BreakAT=25;
    $pagenum = 0;

    for ($num = 0 + ($pagenum * 26); $num <= 200; $num++) {
      
        if($num % $BreakAT == 0){
            if($num>0){
                echo $num . "\r\n";
                $pagenum++;
                return;
            }
        }
        echo $num . "\r\n";
    }
?>
^ Every time you change page number it will only return the 25 results from the array for the current page
 

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
Is this what you're suggesting?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head><body><center>
<div class="display print">

<?php error_reporting (E_ALL ^ E_NOTICE);

// Include config file
require_once "getprerentdb.php";

//MySqli Select Query
$results = $mysqli->query("SELECT * FROM payfile");//Print version

//Set at what record to break at 25 records per page

$BreakAT=25;
$pagenum = 0;

for ($num = 0 + ($pagenum * 26); $num <= 200; $num++) {

if($num % $BreakAT == 0){
if($num>0){
echo $num;
$pagenum++;
return;
}
}
echo $num;
}
$totpaid=0;
// ---------------------------------------
while($row = mysqli_fetch_array($results)) {
// ----------------------------------------
echo date('m/d/y');

?>
<div class="title">Payment Report</div><br />
<table align="center" cellspacing=0 cellpadding=0 border=1>
<thead>
<tr>
<th>tenant</th>
<th>unit</th>
<th>rent paid</th>
<th>rent due</th>
<th>due date</th>
<th>prev bal</th>
<th>late chg</th>
<th>sec dep</th>
<th>damage</th>
<th>court cost</th>
<th>nsf</th>
<th>hud pay</th>
<th>tenant pay</th>
<th>date paid</th>
<th align=left>comment</th>
</tr>
</thead>
<?php
$totpaid += $row['paidsum'];
echo '<tr>
<td>' . $row['tenant'] . '</td>
<td>' . $row['unit'] . '</td>
<td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td>
<td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
<td>' . $row['duedate'] . '</td>
<td align=right class="currency">$'.number_format($row['prevbal'],2).'</td>
<td align=right class="currency">$'.number_format($row['latechg'],2).'</td>
<td align=right class="currency">$'.number_format($row['secdep'],2).'</td>
<td align=right class="currency">$'.number_format($row['damage'],2).'</td>
<td align=right class="currency">$'.number_format($row['courtcost'],2).'</td>
<td align=right class="currency">$'.number_format($row['nsf'],2).'</td>
<td align=right class="currency">$'.number_format($row['hudpay'],2).'</td>
<td align=right class="currency">$'.number_format($row['paidsum'],2).'</td>
<td>' . $row['datepaid'] . '</td>
<td>' . $row['comments'] . '</td>
</tr>';
$num++;
}
}
echo '
<tr>
<th scope="row" colspan="12">Total Paid:</th>
<td bgcolor="#FFD4D4" class="currency">' . number_format($totpaid, 2, '.', '') . '</td>
</tr>
</table>';
?>
</center></div></body></html>
-------------------------------
displays: 012345678910111213141516171819202122232425
 

Cookiegal

Karen
Administrator
Malware Specialist Coordinator
Joined
Aug 27, 2003
Messages
121,335
guitarzRus,

Please use the proper code tags when posting code as Xsage has done so that it displays properly. To do that click on the downward arrow beside the three dots in the menu bar above the reply box and select "Code" then in the next box select the coding language.
 

Xsage

Dave
Joined
Jan 8, 2016
Messages
343
No not quite, this code should work for you. I reordered some stuff tho:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head><body><center>
<div class="display print">

<?php

    error_reporting (E_ALL ^ E_NOTICE);
    // Include config file
    require_once "getprerentdb.php";
    //MySqli Select Query
    $results = $mysqli->query("SELECT * FROM payfile");//Print version
    //Set at what record to break at 25 records per page
    $BreakAT=25;
    $pagenum = 0;
    $totpaid=0;
    echo date('m/d/y');
    echo "\r\nTotal rows: ".count($results)."\r\n";
    echo " Page " . $pagenum . "\r\n";

?>

<div class="title">Payment Report</div><br />
<table align="center" cellspacing=0 cellpadding=0 border=1>
<thead>
<tr>
<th>tenant</th>
<th>unit</th>
<th>rent paid</th>
<th>rent due</th>
<th>due date</th>
<th>prev bal</th>
<th>late chg</th>
<th>sec dep</th>
<th>damage</th>
<th>court cost</th>
<th>nsf</th>
<th>hud pay</th>
<th>tenant pay</th>
<th>date paid</th>
<th align=left>comment</th>
</tr>
</thead>

<?php
    
     for($i = 0 + ($pagenum * $BreakAT); $i < count($results); $i++){

        
        //echo $i % $BreakAT;
        if($i % $BreakAT == 0)
        {
            if($i!=($pagenum * $BreakAT))
            {
                echo '</table class="print">';
                echo '<div class="breakhere"></div>';
                return;
            }
        }
        
        $row = $results[$i];

        $totpaid += $row->paidsum;
        echo "\r\n".($i)."\r\n";

        echo '
        <tr>
        <td>' . $row['tenant'] . '</td>
        <td>' . $row['unit'] . '</td>
        <td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td>
        <td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
        <td>' . $row['duedate'] . '</td>
        <td align=right class="currency">$'.number_format($row['prevbal'],2).'</td>
        <td align=right class="currency">$'.number_format($row['latechg'],2).'</td>
        <td align=right class="currency">$'.number_format($row['secdep'],2).'</td>
        <td align=right class="currency">$'.number_format($row['damage'],2).'</td>
        <td align=right class="currency">$'.number_format($row['courtcost'],2).'</td>
        <td align=right class="currency">$'.number_format($row['nsf'],2).'</td>
        <td align=right class="currency">$'.number_format($row['hudpay'],2).'</td>
        <td align=right class="currency">$'.number_format($row['paidsum'],2).'</td>
        <td>' . $row['datepaid'] . '</td>
        <td>' . $row['comments'] . '</td>
        </tr>';

    }

    echo '
    <tr>
    <th scope="row" colspan="12">Total Paid:</th>
    <td bgcolor="#FFD4D4" class="currency">' . number_format($totpaid, 2, '.', '') . '</td>
    </tr>
    </table>';
?>

</center></div></body></html>
Then all you would need are buttons or something that increases and decreases $pagenum to allow the user to change the page.
 
Last edited:

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
the code gives me this::
07/22/21
Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\property\paymentlist.php on line 19
Total rows: 1 Page 0
Payment Report


Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\property\paymentlist.php on line 47

tenantunitrent paidrent duedue dateprev ballate chgsec depdamagecourt costnsfhud paytenant paydate paid
comment​
Total Paid:0.00
 

Xsage

Dave
Joined
Jan 8, 2016
Messages
343
Ah sorry, I somehow missed the part of the code you had to return the results as an array (because I don't have a database set up to test on so created my own array in code when testing):

You need to add something like:
$results= $results->fetch_all(MYSQLI_ASSOC);
straight after the mysqli query.

Or you can do a while loop like in your original post and assign to a variable like $rows in the same place and change $row = $results[$i]; to $row = $rows[$i];

reference: https://www.php.net/manual/en/mysqli-result.fetch-all.php

the count() method should work after that.
 
Last edited:

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
I must have misunderstood; my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head><body><center>
<div class="display print">

<?php

error_reporting (E_ALL ^ E_NOTICE);
// Include config file
require_once "getprerentdb.php";
//MySqli Select Query
$results = $mysqli->query("SELECT * FROM payfile");//Print version
//Set at what record to break at 25 records per page
$BreakAT=25;
$pagenum = 0;
$totpaid=0;
echo date('m/d/y');
echo "\r\nTotal rows: ".count($results)."\r\n"; // line19
echo " Page " . $pagenum . "\r\n";

?>

<div class="title">Payment Report</div><br />
<table align="center" cellspacing=0 cellpadding=0 border=1>
<thead>
<tr>
<th>tenant</th>
<th>unit</th>
<th>rent paid</th>
<th>rent due</th>
<th>due date</th>
<th>prev bal</th>
<th>late chg</th>
<th>sec dep</th>
<th>damage</th>
<th>court cost</th>
<th>nsf</th>
<th>hud pay</th>
<th>tenant pay</th>
<th>date paid</th>
<th align=left>comment</th>
</tr>
</thead>

<?php
for($i = 0 + ($pagenum * $BreakAT + 1); $i < count($results); $i++) { // line 47
// $row = $results[$i];
$row = $rows[$i];
$totpaid += $row->paidsum;
//echo "\r\n".$i."\r\n";
echo '
<tr>
<td>' . $row['tenant'] . '</td>
<td>' . $row['unit'] . '</td>
<td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td>
<td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
<td>' . $row['duedate'] . '</td>
<td align=right class="currency">$'.number_format($row['prevbal'],2).'</td>
<td align=right class="currency">$'.number_format($row['latechg'],2).'</td>
<td align=right class="currency">$'.number_format($row['secdep'],2).'</td>
<td align=right class="currency">$'.number_format($row['damage'],2).'</td>
<td align=right class="currency">$'.number_format($row['courtcost'],2).'</td>
<td align=right class="currency">$'.number_format($row['nsf'],2).'</td>
<td align=right class="currency">$'.number_format($row['hudpay'],2).'</td>
<td align=right class="currency">$'.number_format($row['paidsum'],2).'</td>
<td>' . $row['datepaid'] . '</td>
<td>' . $row['comments'] . '</td>
</tr>';

if($i % $BreakAT == 0)
{
if($i>0)
{
echo '</table class="print">';
echo '<div class="breakhere"></div>';
return;
}
}
}
echo '
<tr>
<th scope="row" colspan="12">Total Paid:</th>
<td bgcolor="#FFD4D4" class="currency">' . number_format($totpaid, 2, '.', '') . '</td>
</tr>
</table>';
?>
</center></div></body></html>
-------------------------------------------------
gets this:
Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\property\paymentlist4.php on line 19
Total rows: 1 Page 0
Payment Report


Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\property\paymentlist4.php on line 48
0
Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\property\paymentlist4.php on line 48
tenant unit rent paid rent due due date prev bal late chg sec dep damage court cost nsf hud pay tenant pay date paid comment
$0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00
Total Paid: 0.00
 

Xsage

Dave
Joined
Jan 8, 2016
Messages
343
Yeah I think you did misunderstand. Basically in my code above, you need to convert $results from the mysqli response to an array before entering the 'for' loop.

As I said, I don't have a MySQL database set up for me to be able to test from so sorry in advance if these don't work, but try either of these:


PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head><body><center>
<div class="display print">

<?php

    error_reporting (E_ALL ^ E_NOTICE);
    // Include config file
    require_once "getprerentdb.php";
    //MySqli Select Query
    $results = $mysqli->query("SELECT * FROM payfile");//Print version
    $results= $results->fetch_all(MYSQLI_ASSOC);
    //Set at what record to break at 25 records per page
    $BreakAT=25;
    $pagenum = 0;
    $totpaid=0;
    echo date('m/d/y');
    echo "\r\nTotal rows: ".count($results)."\r\n";
    echo " Page " . $pagenum . "\r\n";

?>

<div class="title">Payment Report</div><br />
<table align="center" cellspacing=0 cellpadding=0 border=1>
<thead>
<tr>
<th>tenant</th>
<th>unit</th>
<th>rent paid</th>
<th>rent due</th>
<th>due date</th>
<th>prev bal</th>
<th>late chg</th>
<th>sec dep</th>
<th>damage</th>
<th>court cost</th>
<th>nsf</th>
<th>hud pay</th>
<th>tenant pay</th>
<th>date paid</th>
<th align=left>comment</th>
</tr>
</thead>

<?php
    
     for($i = 0 + ($pagenum * $BreakAT); $i < count($results); $i++){

        
        //echo $i % $BreakAT;
        if($i % $BreakAT == 0)
        {
            if($i!=($pagenum * $BreakAT))
            {
                echo '</table class="print">';
                echo '<div class="breakhere"></div>';
                return;
            }
        }
        
        $row = $results[$i];

        $totpaid += $row->paidsum;
        echo "\r\n".($i)."\r\n";

        echo '
        <tr>
        <td>' . $row['tenant'] . '</td>
        <td>' . $row['unit'] . '</td>
        <td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td>
        <td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
        <td>' . $row['duedate'] . '</td>
        <td align=right class="currency">$'.number_format($row['prevbal'],2).'</td>
        <td align=right class="currency">$'.number_format($row['latechg'],2).'</td>
        <td align=right class="currency">$'.number_format($row['secdep'],2).'</td>
        <td align=right class="currency">$'.number_format($row['damage'],2).'</td>
        <td align=right class="currency">$'.number_format($row['courtcost'],2).'</td>
        <td align=right class="currency">$'.number_format($row['nsf'],2).'</td>
        <td align=right class="currency">$'.number_format($row['hudpay'],2).'</td>
        <td align=right class="currency">$'.number_format($row['paidsum'],2).'</td>
        <td>' . $row['datepaid'] . '</td>
        <td>' . $row['comments'] . '</td>
        </tr>';

    }

    echo '
    <tr>
    <th scope="row" colspan="12">Total Paid:</th>
    <td bgcolor="#FFD4D4" class="currency">' . number_format($totpaid, 2, '.', '') . '</td>
    </tr>
    </table>';
?>

</center></div></body></html>
Or

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head><body><center>
<div class="display print">

<?php

    error_reporting (E_ALL ^ E_NOTICE);
    // Include config file
    require_once "getprerentdb.php";
    //MySqli Select Query
    $results = $mysqli->query("SELECT * FROM payfile");//Print version
    $rows = $results->fetch_array(MYSQLI_BOTH);
    //Set at what record to break at 25 records per page
    $BreakAT=25;
    $pagenum = 0;
    $totpaid=0;
    echo date('m/d/y');
    echo "\r\nTotal rows: ".count($results)."\r\n";
    echo " Page " . $pagenum . "\r\n";

?>

<div class="title">Payment Report</div><br />
<table align="center" cellspacing=0 cellpadding=0 border=1>
<thead>
<tr>
<th>tenant</th>
<th>unit</th>
<th>rent paid</th>
<th>rent due</th>
<th>due date</th>
<th>prev bal</th>
<th>late chg</th>
<th>sec dep</th>
<th>damage</th>
<th>court cost</th>
<th>nsf</th>
<th>hud pay</th>
<th>tenant pay</th>
<th>date paid</th>
<th align=left>comment</th>
</tr>
</thead>

<?php
    
     for($i = 0 + ($pagenum * $BreakAT); $i < count($results); $i++){

        
        //echo $i % $BreakAT;
        if($i % $BreakAT == 0)
        {
            if($i!=($pagenum * $BreakAT))
            {
                echo '</table class="print">';
                echo '<div class="breakhere"></div>';
                return;
            }
        }
        
        $row = $rows[$i];

        $totpaid += $row->paidsum;
        echo "\r\n".($i)."\r\n";

        echo '
        <tr>
        <td>' . $row['tenant'] . '</td>
        <td>' . $row['unit'] . '</td>
        <td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td>
        <td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
        <td>' . $row['duedate'] . '</td>
        <td align=right class="currency">$'.number_format($row['prevbal'],2).'</td>
        <td align=right class="currency">$'.number_format($row['latechg'],2).'</td>
        <td align=right class="currency">$'.number_format($row['secdep'],2).'</td>
        <td align=right class="currency">$'.number_format($row['damage'],2).'</td>
        <td align=right class="currency">$'.number_format($row['courtcost'],2).'</td>
        <td align=right class="currency">$'.number_format($row['nsf'],2).'</td>
        <td align=right class="currency">$'.number_format($row['hudpay'],2).'</td>
        <td align=right class="currency">$'.number_format($row['paidsum'],2).'</td>
        <td>' . $row['datepaid'] . '</td>
        <td>' . $row['comments'] . '</td>
        </tr>';

    }

    echo '
    <tr>
    <th scope="row" colspan="12">Total Paid:</th>
    <td bgcolor="#FFD4D4" class="currency">' . number_format($totpaid, 2, '.', '') . '</td>
    </tr>
    </table>';
?>

</center></div></body></html>
 

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
Man u r good. I've been working on this forever.
This is so close. The code:
-------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head><body><center>
<div class="display print">

<?php

error_reporting (E_ALL ^ E_NOTICE);
// Include config file
require_once "getprerentdb.php";
//MySqli Select Query
$results = $mysqli->query("SELECT * FROM payfile");//Print version
$results= $results->fetch_all(MYSQLI_ASSOC);
//Set at what record to break at 25 records per page
$BreakAT=25;
$pagenum = 0;
$totpaid=0;
echo date('m/d/y');
echo "\r\nTotal rows: ".count($results)."\r\n";
echo " Page " . $pagenum . "\r\n";

?>

<div class="title">Payment Report</div><br />
<table align="center" cellspacing=0 cellpadding=0 border=1>
<thead>
<tr>
<th>tenant</th>
<th>unit</th>
<th>rent paid</th>
<th>rent due</th>
<th>due date</th>
<th>prev bal</th>
<th>late chg</th>
<th>sec dep</th>
<th>damage</th>
<th>court cost</th>
<th>nsf</th>
<th>hud pay</th>
<th>tenant pay</th>
<th>date paid</th>
<th align=left>comment</th>
</tr>
</thead>

<?php

for($i = 0 + ($pagenum * $BreakAT); $i < count($results); $i++){


//echo $i % $BreakAT;
if($i % $BreakAT == 0)
{
if($i!=($pagenum * $BreakAT))
{
echo '</table class="print">';
echo '<div class="breakhere"></div>';
return;
}
}

$row = $results[$i];

$totpaid += $row->paidsum;
echo "\r\n".($i)."\r\n";

echo '
<tr>
<td>' . $row['tenant'] . '</td>
<td>' . $row['unit'] . '</td>
<td align=right class="currency">$'.number_format($row['amtpaid'],2).'</td>
<td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>
<td>' . $row['duedate'] . '</td>
<td align=right class="currency">$'.number_format($row['prevbal'],2).'</td>
<td align=right class="currency">$'.number_format($row['latechg'],2).'</td>
<td align=right class="currency">$'.number_format($row['secdep'],2).'</td>
<td align=right class="currency">$'.number_format($row['damage'],2).'</td>
<td align=right class="currency">$'.number_format($row['courtcost'],2).'</td>
<td align=right class="currency">$'.number_format($row['nsf'],2).'</td>
<td align=right class="currency">$'.number_format($row['hudpay'],2).'</td>
<td align=right class="currency">$'.number_format($row['paidsum'],2).'</td>
<td>' . $row['datepaid'] . '</td>
<td>' . $row['comments'] . '</td>
</tr>';

}

echo '
<tr>
<th scope="row" colspan="12">Total Paid:</th>
<td bgcolor="#FFD4D4" class="currency">' . number_format($totpaid, 2, '.', '') . '</td>
</tr>
</table>';
?>

</center></div></body></html>
--------------------------------------------
the result:
07/23/21 Total rows: 7 Page 0
Payment Report

0 1 2 3 4 5 6
tenant unit rent paid rent due due date prev bal late chg sec dep damage court cost nsf hud pay tenant pay date paid comment
tenant1 apt1 $530.00 $530.00 2021-07-12 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $530.00 2021-07-10
tenant2 apt2 $540.00 $530.00 2021-07-12 $0.00 $10.00 $0.00 $0.00 $0.00 $0.00 $0.00 $540.00 2021-07-15 last time late
tenant3 apt3 $0.00 $530.00 2021-07-12 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 2021-07-12
tenan4 apt4 $575.00 $530.00 2021-07-12 $-45.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $575.00 2021-05-28 overpaid
tenant5 apt5 $0.00 $530.00 2021-07-12 $20.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 0000-00-00
tenant6 apt6 $585.00 $530.00 2021-07-12 $0.00 $0.00 $0.00 $55.00 $0.00 $0.00 $0.00 $585.00 2021-07-20
tenant7 apt7 $555.00 $530.00 2021-07-12 $0.00 $0.00 $25.00 $0.00 $0.00 $0.00 $0.00 $555.00 2021-07-12
Total Paid: 0.00
 

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
I'm sorry, it's my first attempt at pagination and it's so cool. the only issue is
where is the "0 1 2 3 4 5 6" coming from and it doesn't total.
--------------------
07/23/21
Payment Report

0 1 2 3 4 5 6

tenantunitrent paidrent duedue dateprev ballate chgsec depdamagecourt costnsfhud paytenant paydate paid
comment​
tenant1apt1
$530.00​
$530.00​
2021-07-12
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$530.00​
2021-07-10
tenant2apt2
$540.00​
$530.00​
2021-07-12
$0.00​
$10.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$540.00​
2021-07-15last time late
tenant3apt3
$0.00​
$530.00​
2021-07-12
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
2021-07-12
tenan4apt4
$575.00​
$530.00​
2021-07-12
$-45.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$575.00​
2021-05-28overpaid
tenant5apt5
$0.00​
$530.00​
2021-07-12
$20.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
$0.00​
0000-00-00
tenant6apt6
$585.00​
$530.00​
2021-07-12
$0.00​
$0.00​
$0.00​
$55.00​
$0.00​
$0.00​
$0.00​
$585.00​
2021-07-20
tenant7apt7
$555.00​
$530.00​
2021-07-12
$0.00​
$0.00​
$25.00​
$0.00​
$0.00​
$0.00​
$0.00​
$555.00​
2021-07-12
Totals:
0.00​
0.00​
0.00​
0.00​
0.00​
0.00​
0.00​
0.00​
0.00​
0.00​
 

Xsage

Dave
Joined
Jan 8, 2016
Messages
343
the 0 1 2 3 4 5 6 comes from the line echo "\r\n".($i)."\r\n"; I was using this for debugging, you can either get rid of it or comment it out.

As for the totals, in the following code change return; to break;:

PHP:
if($i!=($pagenum * $BreakAT))
{
    echo '</table class="print">';
    echo '<div class="breakhere"></div>';
    break; //here
}
 

Cookiegal

Karen
Administrator
Malware Specialist Coordinator
Joined
Aug 27, 2003
Messages
121,335
guitarzRus,

Please use the proper code tags when posting code as Xsage has done so that it displays properly. To do that click on the downward arrow beside the three dots in the menu bar above the reply box and select "Code" then in the next box select the coding language.
Please do not dismiss my instructions. The code tags are there for a reason.
 

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
Great, just doesn't total. I appreciate the effort and the code tags explanation.
All this text and it said I need more than 3 characters
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top