Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
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 …

635 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