Solved

This code show a lot of result how can I separate 10 result per page

Posted on 2007-04-02
2
165 Views
Last Modified: 2013-12-12
This code show a lot of result how can I separate 10 result per page and have page number to click
in the botom


<?php

$CreCard = 0 ;
$Check = 0 ;
$ToSpay = 0 ;
$ToCreCard = 0 ;
$ToCheck = 0 ;
$RecCreCard = 0 ;
include ("aut.inc");
$link1 = mysql_connect($dbhost, $dbusername, $dbuserpassword) or die("Could not connect (1): " . mysql_error());
mysql_select_db("AOL", $link1) or die("Could not select 'AOL' database: " . mysql_error());
$query = "SELECT `Code`,`InvoiceNo` ,`CName`  ,`RcvAmt` ,`NetAmt`  FROM `sellhead` WHERE (`cancel_b` = 'N' ) AND  LEFT(UDT, 10) > CURDATE() - INTERVAL 150 DAY  ";
$result = mysql_query($query, $link1) or die("Select query error: " . mysql_error());
mysql_close($link1);

$sumNetAmt= 0 ;
$ToSumRev= 0 ;
echo"<tr><td><font size='5'>Today Cash Payment</font>";
echo "<table width=100% cellpadding=0 cellspacing=0 border=1 align=center>
      <tr>
        <td width= 8%><b><font size='1'>Code</font></b></td>
        <td width= 12%><b><font size='1'>InvoiceNo</font></b></td>
        <td width= 24%><b><font size='1'>CName</font></b></td>
        <td width= 5%><b><font size='1'>NetAmt</font></b></td>
        <td width= 5%><b><font size='1'>RcvAmt</font></b></td>
        <td width= 5%><b><font size='1'>CCard</font></b></td>
        <td width= 5%><b><font size='1'>Check</font></b></td>
        <td width= 5%><b><font size='1'>Blance</font></b></td>
        <td width= 5%><b><font size='1'>Comp</font></b></td>
      <td width= 5%><b><font size='1'>D</font></b></td>
      </tr>";
$alternate = "2";
while ($row = mysql_fetch_array($result))
{
      $Code = $row['Code'];
      $invoice = $row['InvoiceNo'];
      $Cname = $row['CName'];
      $NetAmt = $row['NetAmt'];
      $Rcv = $row['RcvAmt'];
      $sumNetAmt= $sumNetAmt + $NetAmt  ;
      $ToSumRev= $ToSumRev+ $Rcv  ;

      // start merge the table
      include("include/dbconnect02.php");
      $link0102 = mysql_connect($dbserver, $dbuser ,  $dbpass ) or die("Could not connect (1): " . mysql_error());
      mysql_select_db("$dbname", $link0102) or die("Could not select 'aola' database: " . mysql_error());
      $query0102 = "SELECT `Paid`, `CreCard` ,`PCheck`   FROM `sellnote` WHERE `Code` = '$Code' ";
      $result0102 = mysql_query($query0102, $link0102) or die("Select query error: " . mysql_error());
      mysql_close($link0102);
      

            while ($row = mysql_fetch_array($result0102))
                  {
                  $Paid = $row['Paid'];
                  $SPay = $row['Paid'];
                  $CreCard = $row['CreCard'];                   
                  $Check = $row['PCheck'];
                  
                  $ToSpay =  $ToSpay + $SPay ;
                  $RecCreCard =  $RecCreCard + $CreCard ;
                  $RecCheck =  $RecCheck + $Check ;
                  
                  $ToSumRev= $ToSumRev + $Paid ;
                  $ToCreCard= $ToCreCard + $CreCard;
                  $ToCheck= $ToCheck + $Check ;
                  }
      
            
            $receiv = $ToSpay + $Rcv ;

            $CreChk = $NetAmt - $receiv -$RecCreCard -$RecCheck;
        $SumCreChk = $SumCreChk + $CreChk ;
            $Check01 = $Check + 0 ;

      if ($CreChk == 0)
      {
                  $Paid = 0 ;
                  $SPay = 0 ;
                  $CreCard =  0 ;                   
                  $Check = 0 ;
                  $ToSpay =  0 ;
                  
                  $RecCreCard =  0 ;
                  $RecCheck =  0 ;
                  
            
                  $ToCreCard= 0 ;
                  $ToCheck= 0 ;
                  
            
            $receiv = 0 ;

            $CreChk = 0;
   
            $Check01 = 0 ;

            $Rcv= 0 ;
            $NetAmt = 0 ;
      }
    else
      {       
    $ToSumRevCre =  $ToSumRevCre + $Rcv + $Paid ;

      $sumNetAmtCre = $sumNetAmtCre + $NetAmt  ;
      $TolCreCard = $TolCreCard + $RecCreCard ;
            if ($alternate == "1")
            {
                  $color = "#ffffff";
                  $alternate = "2";
            }
            else
            {
                  $color = "#efefef";
                  $font = "ffffff";
                  $alternate = "1";
            }
      
      /* each record output*/      
      
            echo"<tr bgcolor=$color><td width =8%><a href='#' onclick=\"window.open('BaDtlA1.php?id=$Code', 'newWin', 'width=500,height=500');\">$Code</a></td>
            <td width =12%>$invoice</td>
            <td width =24%>$Cname</td>
            <td width =5%><p align='right'><font size='3'>$NetAmt</font></td>
            <td width =5%><a href='#' onclick=\"window.open('Receive.php?id=$Code', 'newWin', 'width=500,height=500');\"><p align='right'><font size='3'>$receiv</font></td>
            <td width =5%><a href='#' onclick=\"window.open('Ccard.php?id=$Code', 'newWin', 'width=500,height=500');\"><p align='right'><font size='3'>$RecCreCard</font></td>
            <td width =5%><a href='#' onclick=\"window.open('PayCheck.php?id=$Code', 'newWin', 'width=500,height=500');\"><p align='right'><font size='3'>$RecCheck</font></td>
        <td width =5%><a href='#' onclick=\"window.open('PayCheck.php?id=$Code', 'newWin', 'width=500,height=500');\"><p align='right'><font size='3'>$CreChk</font></td>      
            <td width =5%>m</td>
        <td width =5%><a href='#' onclick=\"window.open('cancel_b.php?id=$Code', 'newWin', 'width=500,height=500');\"><p align='right'>D</td>
         </tr>";

             $SPay = 0 ;
            $ToSpay = 0 ;
            $RecCreCard = 0 ;
            $RecCheck = 0 ;

}
}
echo "</font></table>";

echo "<table width=100% cellpadding=0 cellspacing=0 border=1 >";


echo"<tr bgcolor=#FFFF00>
      <td width =44%>&nbsp;</td>
      <td width = 5%><p align='right'><font size='3'>$sumNetAmtCre</font></td>
      <td width =5%><p align='right'><font size='3'>$ToSumRevCre</font></td>
      <td width =5%><p align='right'><font size='3'>$TolCreCard</font></td>
      <td width =5%><p align='right'><font size='3'>$ToCheck</font></td>
   <td width =5%><p align='right'><font size='3'>$SumCreChk</font></td>
    <td width= 5%><b><font size='1'>D</font></b></td>
      <td width= 5%><b><font size='1'>D</font></b></td>
      </tr>";

echo "</font></table> <br><br><hr color = green >";
                        

?>
0
Comment
Question by:teera
2 Comments
 
LVL 18

Accepted Solution

by:
Mark Gilbert earned 250 total points
ID: 18835946
0
 
LVL 2

Assisted Solution

by:wakemup
wakemup earned 250 total points
ID: 18837726
One suggestion:

Learn SQL. Let the db do the hard work. RDMSs' have been around for 30+ years and they can crunch numbers seriously.

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question