Solved

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

Posted on 2007-04-02
2
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
if statement malfunction 5 44
PHP URL Parameter to simple URL for single folder 16 48
history of pages 7 52
Load string Array from file 23 42
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

739 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