0

我使用 php,我的代码是

<?php
require_once( "conn/conn.php");
require_once( "includes/session.php" );
require_once( "includes/function.php" );
require_once( "includes/classes.php" );
if( $_GET['set_i'] == 'template' ) {
    $get_uc = $_GET['uc'];
    $get_un = $_GET['un'];

    $pdfile = "pdf/" . $get_uc . "_" . $get_un . ".html";
    $fh = fopen($pdfile, 'w') or die("can't open file");
    $pageData = '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js"></script>
<script type="text/javascript" src="../js/tem.js"></script>

<link href="../css/tem.css" rel="stylesheet">
<title>Quo-System</title>
</head>

<body>
<div id="wrap">
<article>
<form method="post">
    <div class="page">
    ';
        $set = SET_SQL( "SELECT * FROM jon_company WHERE user_code = '". $_SESSION['user_code'] ."' and `set`='1' " );
        $set_logo = SET_SQL( "SELECT * FROM jon_com_logo WHERE user_code = '". $_SESSION['user_code'] ."' " );
        $set_logo_img = SET_SQL( "SELECT * FROM jon_com_logo_img WHERE user_code = '". $_SESSION['user_code'] ."' " );
        $set_com_for = SET_SQL( "SELECT * FROM jon_com_for WHERE user_code = '". $_SESSION['user_code'] ."' and `set`='1' " );
        $set_position = SET_SQL( "SELECT * FROM jon_com_add WHERE user_code = '". $_SESSION['user_code'] ."' " );

        $set_total = SET_SQL( "SELECT * FROM jon_com_quo_computation WHERE user_code = '".$_SESSION['user_code']."' and com_code = '".$_GET['ccom']."' and active='1' " );

    $pageData .= '
        <div class="logo" align='.$set_logo['logo_position'].' style="margin:20px;">    
            <img src="../images/upload/' . $set_logo_img['filename'] . '" width='.$set_logo['logo_width'].' align="center" id="img_logo" />
        </div>

        <div class="company_name" align="'.$set_position['add_position'].'" style="font-family:'.$set_position['font_type'].'; font-size:'. $set_position['font_size'] .'px; padding-left:10px; padding-right:10px; width:580px;">
            <strong>'.$set['com_name'].'</strong><br />
            '.$set['address'].'<br />
            '.$set['post_code'].' - '.$set['city'].'<br />
            '.$set['country'].'
        </div>
        <br />
        <div class="company_details" align="left" style="margin-left:500px;padding:10px;">
            '.$set['email'].'<br /><br />
            KVK : '.$set['kvk_no'].'<br />
            VAT : '.$set['vat_no'].'<br />
            BANK : '.$set['bank_acct'].'<br />
        </div>
        <br />
        <div class="company_quo_for" style="margin-top:-100px; padding:10px;">
        ';
            if ( empty( $set_com_for ) ){
                $pageData .= 'No record found! Please set Company for the template.';
            } else {
                $pageData .= '<b>'. $set_com_for['company_name_for'] .' </b><br />
                '. $set_com_for['street_name'] . '<br /> 
                '. $set_com_for['post_code'] .  ' "&nbsp;" ' . $set_com_for['city'] . '<br />
                '. $set_com_for['country'] . ' "<br />" 
                '. date( "F h, Y", strtotime( $set_com_for['date'] ) ) . ' <br />';
            }       
    $pageData .= '  
            <input type="hidden" name="com_name_for" value="'. $set_com_for['compnay_name_for'] . '" />
        </div>

        <div class="quotation_date" style="text-align:right; position:relative; top:50px; right:75px;">

            ';

            $new_date = mktime(0, 0, 0, date("m"), date("d")+15, date("y"));
            $exdate = date("Y-m-d", $new_date);

    $pageData .='
            Date : ' . date( "Y-d-m" ) . ' <br />
            Expiration Date : ' . $exdate . '
        </div>

        <div class="quotation_number" style="padding-left:10px;">
            <h2>' . $set_com_for['sub_quo'] . '</h2>
            <h3>Quotation Number : ' . date( "Y" ) . ' - ' . $set_total['invoice_num'] . ' </h3>
        </div>

        <div class="quotation_computation" style="margin-top:50px;">
            <table cellpadding="5" cellspacing="0" width="100%">
                <tr>
                    <th>#</th>
                    <th>Definition</th>
                    <th>Amount</th>
                    <th>Total</th>
                    <th>BTW</th>
                </tr>
                ';
                $get_total_computation = SET_SQL( "SELECT * FROM jon_com_quo_computation WHERE user_code = '". $get_uc ."' and com_code = '".$_GET['ccom']."' and active='1' " );
                if ( $get_total_computation['currency'] == "euro" ) {
                    $msg_tot .= "&euro;";
                } elseif ( $get_total_computation['currency'] == 'usd' ) {
                    $msg_tot .= '&#36;';
                }
                $get_details = mysql_query( "SELECT * FROM jon_com_quo_computation WHERE user_code = '". $get_uc ."' and active = '1' " ) or die ( mysql_error());
                $found_record = mysql_num_rows( $get_details );
                if ( $found_record != 0 ) {
                while( $set_det = mysql_fetch_array( $get_details ) ) {
                 $total = $set_det['quo_quantity'] * $set_det['quo_amt'];
        $pageData .= '  
                <tr>
                    <td class="add_text">
                        <input type="hidden" name="computation_id" value="'.$get_details['q_id'].'" />
                        '.$set_det['quo_quantity'].' x
                    </td>
                    <td class="add_text" width="250">'.$set_det['quo_definition'].'</td>
                    <td class="add_text">
                        '.$msg_tot
                        .$set_det['quo_amt'].'
                    </td>
                    <td class="add_text" id="total">
                    ' . $msg_tot . $total;
                    $pageData .= '
                    <input type="hidden" name="sumof" value="'.$total.'" />
                    </td>
                    <td class="add_text">'.$set_det['quo_btw'].'</td>
                </tr>
                ';
                    }
                } else {
    $pageData .= '<tr>
                    <td colspan="5" align="center" style="background-color:#C6F5FB;"><span>No record found!</span></td>
                </tr>
                ';
                }
   $pageData .= '</table>
        </div>

        <div class="sub_total_computation" style="width:250px; position:relative; left:325px;">
            <table cellpadding="5" cellspacing="0" width="100%">
                <tr>
                    <td><strong>Sub Total</strong></td>
                    <td>'
                         . $msg_tot                     
                         . '<span id="total_f"></span>
                        <input type="hidden" name="total_f" value="" />
                    </td>
                </tr>
                <tr>
                    <td>
                        BTW
                    </td>
                    <td>
                     '
                    . $get_total_computation['quo_btw']
                    . $get_per = explode( '%', $get_total_computation['quo_btw'])
                    . ' 
                        <input type="hidden" name="btw" value="' .$get_per[0] .'" />
                        <input type="hidden" name="com_track" value="'.$get_total_computation['com_track'].'" />
                     </td>
                </tr>
                <tr>
                    <td><strong>Total</strong></td>
                    <td>
                        '
                    . $msg_tot
                    . ' 
                        <span id="s_btw"></span>
                        <input type="hidden" name="s_btw" value="" />
                    </td>
                </tr>
            </table>
        </div>

        <div class="quotation_footer" style="margin-top:200px; border-top:1px dotted #999;">
            <div id="ft">
            <span>
        ';
            $get_footer_txt = SET_SQL( "SELECT * FROM jon_footer_txt WHERE user_code = '". $get_uc ."' and com_code = '".$_GET['ccom']."' ORDER BY t_id DESC" );
            if ( empty( $get_footer_txt ) ) {
                $msg_footer = 'Please select Footer Tab and insert footer text.';
            } else {
                $msg_footer = '<p>' .$get_footer_txt['footer_txt'].'</p>';
            }
    $pageData .= $msg_footer . '
            </span>
            </div>
        </div>
    </div>
</form>
</article>
</div>

</body>
</html>

    ';

    fwrite($fh, $pageData);
    fclose($fh);
}

?>

但是我遇到了问题,if else statement$pageData .=不知道如何将其放入该变量中。

因此,当我将其转换为 HTML 时,缺少来自 if else 语句的文件。

这是我遇到问题的线路。

$get_total_computation = SET_SQL( "SELECT * FROM jon_com_quo_computation WHERE user_code = '". $get_uc ."' and com_code = '".$_GET['ccom']."' and active='1' " );
if ( $get_total_computation['currency'] == "euro" ) {
    $msg_tot .= "&euro;";
} elseif ( $get_total_computation['currency'] == 'usd' ) {
    $msg_tot .= '&#36;';
}

我怎么能把它放进去$pageData

如果我尝试这样的事情

$get_total_computation = SET_SQL( "SELECT * FROM jon_com_quo_computation WHERE user_code = '". $get_uc ."' and com_code = '".$_GET['ccom']."' and active='1' " );
if ( $get_total_computation['currency'] == "euro" ) {
    $pageData .= "&euro;";
} elseif ( $get_total_computation['currency'] == 'usd' ) {
    $pageData .= '&#36;';
}

它甚至不读取 var,但它会重复显示页面。

谢谢你,先生。

4

0 回答 0