Solved

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

Posted on 2007-04-02
2
166 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

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