CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: PHP to EXCEL

Threaded View

  1. #7
    Join Date
    Dec 2008
    Posts
    27

    Re: PHP to EXCEL

    MOD i have another question.

    my data fetching is already ok with this code.

    PHP Code:
    <?php
        
        
    include("conn_db.php");

    $output = array();
    $output[] = "SO No.\tProduct\tModel No.\tWarranty\t";

    // connect to mysql database

    $num 1;
    $query "SELECT so.so_no, pr.description as product, pr.model_no, w.warranty
                FROM service_order AS so
                LEFT JOIN product as pr ON pr.prod_id = so.prod_id
                LEFT JOIN product_category as pc ON pc.code_cat = pr.code_cat
                LEFT JOIN warranty as w ON w.warranty_id = so.warranty_id
                
    $sql = mysql_query($query);
    while (
    $row = mysql_fetch_object($sql)) {
      
    $output[] = $row->so_no . "\t" . $row->product . "\t" . $row->model_no . "\t" . $row->warranty . "\t";
      
    $num++;
    }
    mysql_free_result(
    $sql);

    // disconnect from database

    $data = implode("\n", $output);

    header("
    Content-typeapplication/x-msdownload"); 
    header("
    Content-Dispositionattachmentfilename=extraction.xls"); 
    header("
    Pragmano-cache"); 
    header("
    Expires0"); 
    print "
    $header\n$data"; ?>
    but when i try to add this query i got many errors

    PHP Code:
    $result mysql_query("SELECT * FROM so_trouble_reported WHERE so_no = $so_no");
            
    $getTr_id mysql_fetch_array($result);
            
    $result mysql_query("SELECT * FROM trouble_reported WHERE tr_id = ".$getTr_id["tr_id"]);
            
    $getTrCode mysql_fetch_array($result); 

    i put this right after my last LEFT JOIN and i got errors.
    now. where should i put this query? i like to use the var $getTrCode
    Last edited by ryanbong; February 19th, 2009 at 01:04 AM. Reason: added tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured