geen waarden return van database mysql

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Pierre vanneck

pierre vanneck

16/02/2012 11:22:33
Quote Anchor link
heb een functie die gedeeltelijk de values retourneert. Heb alles nagecheckt doch vind de juiste script fout niet.Vreemde is dat de waarden wel worden geretourneerd van de database met de $order_description en niet werkt met de $order.Misschien de echo " niet juist geplaatst.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
function draw_invoice($order_id) {
    global $db,$db1;
    $sql="SELECT
        "
._DB_PREFIX."orders.id AS order_id,
        "
._DB_PREFIX."orders.order_status,
        "
._DB_PREFIX."transactions.transaction_date,
        "
._DB_PREFIX."transactions.total_sum,
        "
._DB_PREFIX."transactions.sales_tax,
        "
._DB_PREFIX."transactions.shipping_charge,
        "
._DB_PREFIX."paymentInstruments.instrument_name,
        "
._DB_PREFIX."paymentTypes.payment_description,
        "
._DB_PREFIX."participantAddresses.*,
        "
._DB_PREFIX."participants.username,
        "
._DB_PREFIX."shipment_types.service AS ups_service,
        CONCAT("
._DB_PREFIX."participants.firstname,' ',"._DB_PREFIX."participants.lastname) AS participant_name

    FROM "
._DB_PREFIX."orders
    INNER JOIN "
._DB_PREFIX."participants ON "._DB_PREFIX."orders.participant_id="._DB_PREFIX."participants.id
    INNER JOIN "
._DB_PREFIX."participantAddresses ON "._DB_PREFIX."participants.id="._DB_PREFIX."participantAddresses.participant_id
    INNER JOIN "
._DB_PREFIX."transactions ON "._DB_PREFIX."orders.trans_id = "._DB_PREFIX."transactions.id     
    INNER JOIN "
._DB_PREFIX."paymentTypes ON "._DB_PREFIX."transactions.payment_type = "._DB_PREFIX."paymentTypes.payment_type
    INNER JOIN "
._DB_PREFIX."shipment_types ON "._DB_PREFIX."orders.ups_service_id="._DB_PREFIX."shipment_types.ups_service_id
    INNER JOIN "
._DB_PREFIX."paymentInstruments ON "._DB_PREFIX."transactions.payment_instrument="._DB_PREFIX."paymentInstruments.id
    WHERE "
._DB_PREFIX."orders.id='".$order_id."'";
    $db->query($sql);
    
    $order=$db->fetchAssoc();
    echo "<script>
    function Clickheretoprint(){
        var disp_setting='toolbar=yes,location=no,directories=yes,menubar=yes,';
        disp_setting+='scrollbars=yes,width=650, height=600, left=100, top=0';
        var content_vlue = document.getElementById('print_content').innerHTML;
  
        var docprint=window.open('','',disp_setting);
        docprint.document.open();
        docprint.document.write('<html><head><title></title>');
        docprint.document.write('</head><body onLoad=\"self.print()\"><center>');
        docprint.document.write('<div  align=\"left\">');        
        docprint.document.write(content_vlue);
        docprint.document.write('</div>');          
        docprint.document.write('</center></body></html>');
        docprint.document.close();
        docprint.focus();
    }
    </script>"
;
    echo "<br/>
        <div style='border:1px solid #e2e0cb;' id='print_content' >    
        <br/>
        <center><b>Invoice for order #"
.$order['order_id']."</b></center>
        <table align=center class='default_dg_table' style='border:0px;' width='80%'>
        <tr>
            <td align='left'>&nbsp;</td>
            <td align='right'><a style='cursor: pointer;' onclick='Clickheretoprint()'><img src='modules/datagrid/images/default/print_b.gif' onmouseover='this.src=\"modules/datagrid/images/default/print_r.gif\"' onmouseout='this.src=\"modules/datagrid/images/default/print_b.gif\"' alt='Printable View' title='Printable View'></a></td>
        </tr>
        </table>
        <br/>
        <table align=center class='default_dg_table' width='80%'>
        <tr>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Ship To:</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Bill To:</th>
        </tr>
        <tr>
            <td class='default_dg_td dg_left'>
                "
.$order['participant_name']."<br/>
                "
.$order['shipping_address1']."<br/>
                "
.$order['shipping_address2']."<br/>
                "
.city($order['shipping_city'])."".($order['shipping_state']!=""?",&nbsp;".$order['shipping_state']:"")."<br/>
                "
.country($order['shipping_country'])."<br/>
                "
.$order['shipping_postcode']."<br/>
            </td>
            <td class='default_dg_td dg_left'>
                "
.$order['participant_name']."<br/>
                "
.$order['billing_address1']."<br/>
                "
.$order['billing_address2']."<br/>
                "
.city($order['billing_city'])."".($order['billing_state']!=""?",&nbsp;".$order['billing_state']:"")."<br/>
                "
.country($order['billing_country'])."<br/>
                "
.$order['billing_postcode']."<br/>
            </td>
        </tr>
        </table>
        <br/><br/>
        <table align=center class='default_dg_table' width='80%'>
        <tr>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Order #</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Invoice Date</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Type</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Status</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Shipping</th>
        </tr>
        <tr>
            <td class='default_dg_td dg_center'>"
.$order['order_id']."</td>
            <td class='default_dg_td dg_left'>"
.date("d/m/Y",strtotime($order['transaction_date']))."</td>
            <td class='default_dg_td dg_left'>"
.$order['payment_description']."</td>
            <td class='default_dg_td dg_left'>"
.$order['order_status']."</td>
            <td class='default_dg_td dg_left'>"
.$order['ups_service']."</td>
        </tr>
    </table><br/><br/>"
;
    $sql = "SELECT
                    "
._DB_PREFIX."orderDescription.id,
                    "
._DB_PREFIX."products.item_code,
                    "
._DB_PREFIX."products.product_name,
                    "
._DB_PREFIX."products.ibo_price,
                    "
._DB_PREFIX."products.bv_points,
                    "
._DB_PREFIX."orderDescription.quantity,
                    "
._DB_PREFIX."orderDescription.product_price,
                    ("
._DB_PREFIX."orderDescription.product_price * "._DB_PREFIX."orderDescription.quantity) as total_ibo_price,
                    ("
._DB_PREFIX."orderDescription.product_bv * "._DB_PREFIX."orderDescription.quantity) as total_bv_points,
                    "
._DB_PREFIX."orderDescription.order_id,
                    "
._DB_PREFIX."orderDescription.product_id
            FROM "
._DB_PREFIX."orderDescription
                INNER JOIN "
._DB_PREFIX."products ON "._DB_PREFIX."orderDescription.product_id = "._DB_PREFIX."products.id
            WHERE "
._DB_PREFIX."orderDescription.order_id = '".$order_id."'";
    $db1->query($sql);
    if ($db1->numRows()>0) {
        echo "
        <table align=center class='default_dg_table' width='80%'>
        <tr>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Item #</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Description</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Price</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Quantity</th>
            <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Totals</th>
        </tr>"
;
        $total=0;
        while($order_description=$db1->fetchAssoc()) {
            $total +=$order_description['total_ibo_price'];
            echo "<tr>
            <td class='default_dg_td dg_center'>"
.$order_description['item_code']."</td>
            <td class='default_dg_td dg_left'>"
.$order_description['product_name']."</td>
            <td class='default_dg_td dg_left'>&euro;"
.$order_description['product_price']."</td>
            <td class='default_dg_td dg_center'>"
.$order_description['quantity']."</td>
            <td class='default_dg_td dg_left'>&euro;"
.$order_description['total_ibo_price']."</td>
        </tr>"
;
        }

        echo "</table>";
    }

    echo "<br/><br/>
        <table align=center border=0 width='80%'>
        <tr>
        <td width='60%' valign='top'>
            <table class='default_dg_table' width='100%'>
            <tr>
                <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Payment Date</th>
                <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Payment Type</th>
                <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Amount</th>
            </tr>
            <tr>
                <td class='default_dg_td dg_left'>"
.$order['transaction_date']."</td>
                <td class='default_dg_td dg_left'>"
.$order['instrument_name']."</td>
                <td class='default_dg_td dg_left'>&euro;"
.$order['total_sum']."</td>
            </tr>
            </table>
        </td>
        <td width='40%' align='left' valign='top'>
            <table class='default_dg_table' width='100%'>
            <tr>
                <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Sub Total</th>
                <td class='default_dg_td dg_left'>&euro;"
.$total."</td>
            </tr>
            <tr>
                <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Tax Total</th>
                <td class='default_dg_td dg_left'>&euro;"
.$order['sales_tax']."</td>
            </tr>
            <tr>
                <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Shipping Total</th>
                <td class='default_dg_td dg_left'>&euro;"
.$order['shipping_charge']."</td>
            </tr>
            <tr>
                <th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Grand Total</th>
                <td class='default_dg_td dg_left'>&euro;"
.$order['total_sum']."</td>
            </tr>        
            </table>
        </td>
        </tr>
        </table>
    "
;
    //<div style='clear:both;height:10px;'></div>";
    
    echo "<br/><br/></div><br/><br/>";
}
    


?>
 
PHP hulp

PHP hulp

28/04/2024 02:46:44
 
Roel -

Roel -

16/02/2012 11:24:14
Quote Anchor link
Even een puntje trouwens, echo nooit in een functie!
 
Pierre vanneck

pierre vanneck

16/02/2012 13:35:11
Quote Anchor link
thx

Toevoeging op 16/02/2012 13:48:47:

zonder echo geen return . Is dat niet wat de fout creert.

Toevoeging op 16/02/2012 13:52:41:

anders kreeg ik geen return values bij gebruik van $order_description dewelke ook werkt met echo.
 
Roel -

Roel -

16/02/2012 14:02:48
Quote Anchor link
In een functie bouw je een return value op, die je op het laatst returnt en bij de aanroep van de functie opvangt met bijvoorbeeld een echo of in een variabel stopt.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
<?php
function hallo()
{

    return 'Hallo';
}


echo hallo();
?>
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.