Jump to content

maideen

Members
  • Posts

    36
  • Joined

  • Last visited

Posts posted by maideen

  1. hi.
    I need to generate the ageing report like 
    Code   Name    30days   60days    90days   120days
    0001   abc       500.85   675.90    100.78    56.90
    0002   def       123.00     0.00      21.00      67.09
    
     
    My code is below. But Nothing is appear. Pls if anyone knows pls help me
    connection.inc.php
    <?php
       try {
            $hostname = "server";            //host
            $dbname = "database";            //db name
            $username = "user";            // username like 'sa'
            $pw = "password";                // password for the user
            $dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");
        } 
     
      catch (PDOException $e) 
        {
            echo "not connected " . $e->getMessage() . "\n";
            file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
            exit;
        }
    ?>
    
     
    index.php
     
    <?php
     
    include_once '../inc/connection.inc.php';
    include 'searchform.html.php';
    ?>
    <?php
     
    /*
     
    if (isset($_POST['datefrom']) && $_POST['datefrom']  != "" )
        {
           
           $datefrom = $_POST["datefrom"];
           
           $stmt = $dbh->query("SELECT Code,Name,
                  SUM(CASE WHEN DocDate >= '$datefrom' - 30 THEN Balance ELSE 0 END) AS d30, 
                  SUM(CASE WHEN DocDate BETWEEN '$datefrom' - 60 AND '$datefrom' - 31  THEN Balance ELSE 0 END) AS d60, 
                  SUM(CASE WHEN DocDate < '$datefrom' - 60 THEN Balance ELSE 0 END) AS above61,
                  SUM(Balance) AS total_outstanding FROM AgeingReport GROUP BY Code");  
           
          $stmt->setFetchMode(PDO::FETCH_ASSOC);           
        }
        include 'view.html.php';
        exit();
    */
    ?>
     
    <?php
     
    if (isset($_POST['datefrom']) && $_POST['datefrom']  != "" )
        {
     
        $datefrom = $_POST["datefrom"];
     
        $stmt=$dbh->prepare(" SELECT Code, Name, DATEDIFF('$datefrom', DocDate) AS days_past_due,
                            SUM(IF(days_past_due = 0, Balance, 0) As curent),
                            SUM(IF(days_past_due BETWEEN 1 AND 30, Balance, 0) As d30),
                            SUM(IF(days_past_due BETWEEN 31 AND 60, Balance, 0) As d60),
                            SUM(IF(days_past_due BETWEEN 61 AND 90, Balance, 0) As d90),
                            SUM(IF(days_past_due > 90, Balance, 0) As d90above)
                            FROM AgeingReport GROUP BY Code");
     
        $stmt->setFetchMode(PDO::FETCH_ASSOC);  
      }
        include 'view.html.php';
        exit();
     
    ?>
    
     
    searchform.html.php
     
    <?php
    include '../templete/header.php';
    ?>
    <div>
        <h6>Ageing Report</h6>
    </div>
     
    <form action="" method="post">
    <table class="tdtable" id="tdtable">
                     
          <tr>
            <td>As on:</td>
            <td><input type="text" id="datepicker1" name="datefrom" /></td>
          </tr>
       
    </table>
        <div>
            <input type="submit" value="Search">
        </div>
    </form>
    
     
     
    view.html.php
     
    <?php //include '../templete/header.php'; ?>
     
     
    <table width="100%" align="center" cellpadding="4" cellspacing="1" class=tbl_table">
      <tr>
        <td class="tbl_header">MV CODE</td>
        <td class="tbl_header">MV NAME</td>
        <td class="tbl_header">Current</td>
        <td class="tbl_header">30-days</td>
        <td class="tbl_header">60-days</td>
        <td class="tbl_header">90-days</td>
        <td class="tbl_header">90-days above</td>
        
     
      </tr>
            <?php 
              if(isset($stmt))
                { 
                    while($row = $stmt->fetch())
                {?>
        <tr>
          <td class="tbl_content"><?php echo $row['Code'];?></td>
          <td class="tbl_content"><?php echo $row['Name'];?></td>
          <td class="tbl_content"><?php echo $row['SONo'];?></td>
          <td class="tbl_content_right"><?php echo number_format(current,2) ;?></td>
          <td class="tbl_content_right"><?php echo number_format(d30,2) ;?></td>
          <td class="tbl_content_right"><?php echo number_format(d60,2) ;?></td>
          <td class="tbl_content_right"><?php echo number_format(d90,2) ;?></td>
          <td class="tbl_content_right"><?php echo number_format(d90above,2) ;?></td>
      <!--
          <td>
              <a href="view?=<?php echo $row['SVCode'];?>">View</a> |
              <a href="edit?=<?php echo $row['SVCode'];?>">Edit</a> |
              <a href="delete?=<?php echo $row['SVCode'];?>">Delete</a>
          </td>
        -->
        </tr>
        
        <?php 
            //$balamt+=$row['BalAmt'];
           // $balqty+=$row['BalQty'];
           // $rtnqty+=$row['RTNQty'];
           // $qty+=$row['Qty'];
            
        }}?> 
     
     
     
     
    <tr><td colspan="9"><hr /></tr>
     
    <tr>  
          <!--
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td class="tbl_content_total">  <?php echo number_format($qty);?></td>
          <td class="tbl_content_total">  <?php echo number_format($rtnqty);?></td>
          <td class="tbl_content_total">  <?php echo number_format($balqty);?></td>
          <td class="tbl_content_total">  <?php echo number_format($balamt,2);?></td>
          -->  
    </tr>
    </table>
     
     
    <?php unset($dbh); unset($stmt); ?>
     
    <?php
    include '../templete/footer.php';
    ?>
     
    
     
    Pls help me
     
    maideen
     

     

  2. Hi 

    I am not familiar with ajax. pls help me how i can do in script

    Below my script  and using pdo and mssql 2005. Below script working fine. But everytime change the details, page refresh and display is delayed

     

    Pls help me

     

    ---------------------------------------------------------------------------

    index.php

    ----------------------------------------------------------------------------------------------

     

     

    <?php
    include_once '../inc/connection.inc.php';
    ?>
     
    <?php
    try {
           $stmt = $dbh->prepare('SELECT * FROM MVendorMaster order by MVName');
           $stmt->execute();
        } 
    catch (PDOException $e) 
        {
           $output = 'Error fetching main vendor from database!';
           include '../errormsg.php';
           exit();
        }
     
    foreach ($stmt as $row) 
        {
           $mvcode[] = array('MVCode' => $row['MVCode'], 'MVName' => $row['MVName']);
        }
    include 'searchform.html.php';
    ?>
     
    <?php
    if (isset($_POST['mvendor']) && $_POST['mvendor']  != "" )
        {
            $mvcode = $_POST["mvendor"];
            $datefrom=$_POST["datefrom"];
            $dateto=$_POST["dateto"];
            
            $stmt = $dbh->query("SELECT * FROM InvoiceHead WHERE MVCode='$mvcode' and SODate>='$datefrom' and SODate<='$dateto' order by SODate");  
            $stmt->setFetchMode(PDO::FETCH_ASSOC);  
         }
        include 'view.html.php';
        exit();
       
    ?>
     
    ---------------------------------------------------------
    searchform.html.php

    -------------------------------------------

     

     

    <?php
    include '../templete/header.php';
    ?>
     
    <form action="" method="post">
            <table>
                  <tr>
                      <td>Main Vendor Name </td>
                      <td>
                          <select name="mvendor" id="mvcode"><option value="">Mian Vendor</option>
                        <?php foreach ($mvcode as $mvcodes): ?>
                            <option value="<?php htmlout($mvcodes['MVCode']); ?>">
                                <?php htmlout($mvcodes['MVName']); ?></option>
                        <?php endforeach; ?>
                        </select>
                            
                      </td>
                      
                  </tr>
                  <tr>
                    <td>Date[From]:</td>
                    <td><input type="text" id="datepicker1" name="datefrom" /></td>
                  </tr>
                  <tr>
                    <td>Date[To]:</td>
                    <td><input type="text" id="datepicker2" name="dateto" /></td>
                  </tr>    
     
     
            </table>
      
            <div>
                
                <input type="submit" value="Search">
            </div>
    </form>
     

    ------------------------------------------------------------------------

    view.html.php

     

    -----------------------------------------------------------------------

     

     

    <?php //include '../templete/header.php'; ?>
    <script language="javascript" type="text/javascript">
         //window.print();
    </script>
     
    <script type="text/javascript">
     
            function PrintGridData() {
                var prtGrid = document.getElementById('<%=txtDocNo%>');
                prtGrid.border = 0;
                var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
                prtwin.document.write(prtGrid.outerHTML);
                prtwin.document.close();
                prtwin.focus();
                prtwin.print();
                prtwin.close();
     </script>
     
    <table width="100%" align="center" cellpadding="4" cellspacing="1" class=tbl_table">
      <tr>
        <td class="tbl_header">MV CODE</td>
        <td class="tbl_header">MV NAME</td>
        <td class="tbl_header">SONO</td>
        <td class="tbl_header">SO Date</td>
        <td class="tbl_header">RATE</td>
        <td class="tbl_header">SUPP.QTY</td>
        <td class="tbl_header">RTN.QTY</td>
        <td class="tbl_header">BAL.Qty</td>
        <td class="tbl_header">SOLD AMT</td>
        
        
        
        <td class="tbl_header">Actions</td>
        
     
      </tr>
            <?php 
       
            
     
            if(isset($stmt))
                { 
                    while($row = $stmt->fetch())
                {?>
        <tr>
          <td class="tbl_content"><?php echo $row['MVCode'];?></td>
          <td class="tbl_content"><?php echo $row['MVName'];?></td>
          <td class="tbl_content"><?php echo $row['SONo'];?></td>
          <td class="tbl_content"><?php echo date("d-m-Y", strtotime($row['SODate']));?></td>
          <td class="tbl_content_right"><?php echo number_format($row['Rate'],2) ;?></td>
          <td class="tbl_content_right"><?php echo number_format($row['Qty']) ;?></td>
          <td class="tbl_content_right"><?php echo number_format($row['RTNQty']) ;?></td>
          <td class="tbl_content_right"><?php echo number_format($row['BalQty']) ;?></td>
          <td class="tbl_content_right"><?php echo number_format($row['BalAmt'],2) ;?></td>
          <!--number_format
          <td>
              <a href="view?=<?php echo $row['SVCode'];?>">View</a> |
              <a href="edit?=<?php echo $row['SVCode'];?>">Edit</a> |
              <a href="delete?=<?php echo $row['SVCode'];?>">Delete</a>
          </td>
        -->
        </tr>
        <?php }}?> 
    </table>
     
    <?php unset($dbh); unset($stmt); ?>
     
    <?php
    include '../templete/footer.php';
    ?>
     

    ---------------------------------------------

    Data connection

    ---------------------------------------------

     

    <?php
      try {
            $hostname = "server";            //host
            $dbname = "db1";            //db name
            $username = "sa";            // username like 'sa'
            $pw = "7hjer34s$%";                // password for the user
            $dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");
        } 
     
      catch (PDOException $e) 
        {
            echo "cannot connect " . $e->getMessage() . "\n";
            file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
            exit;
        }
    ?>

     

    Pls help how can i add ajax in this page

     

    thanking you

     

    maideen

  3. Hi, I am new in PHP. I have tried to connect MSSQL 2005 through php.

    I am using xampp 1.8.0 

    But once run, error msg is "Fatal error: Call to undefined function mssql_query()".

    I have copied  "php_mssql.dll" in PHP folder  and enable in PHP.ini as "extension=php_mssql.dll "

    and also tried copied in PHP/ext folder also (all above got from forum PHP Freaks Previous topics)

     

    But nothing happened. Same error appear. Can anybody help?

     

    Pls Help me.

     

    Below is code.  I am running xampp in my local mechine with Win 7 pro

     

    It is config.php

     

     

    <?php
    $myServer = "sils-pc";
    $myUser = "sa";
    $myPass = "544Hjy%2*2";
    $myDB = "tempDB"; 
        
    $conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
    $connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB; 
    $conn->open($connStr); 
    ?>

     

     

     

    <?php
    include 'config.php';
    $query = "SELECT * FROM vw_Film_Certs_Display order by id";
    //$query = mssql_query('SELECT * FROM
    .[dbo].[vw_Film_Certs_Display]');
    $result = mssql_query($query);
    $numRows = mssql_num_rows($result); 
    echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>"; 
    while($row = mssql_fetch_array($result))
    {
      echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
    }
    mssql_close($dbhandle);
    ?>

     

    Please help me

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.