Solved

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

Posted on 2007-04-02
2
164 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:
ingwa 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Saving image into server to get url later 1 31
php call to a non-object 3 32
Access Object's Property 9 22
unset shopping cart session 15 31
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…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now