Totale prijs?

Gestart doorShahiem8 reacties32 weergaven

9 berichten · pagina 1 van 1

Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hi,

Ik ben bezig met een winkelmand, maar hij moet het totale bedrag berekenen.
Maar dat doet hij niet, weet iemand een oplissing? smile
$winkelmandQuery = $core->mysql->query("SELECT
                                                                    p.naam,
                                                                    p.afbeelding_klein,
                                                                    p.prijs,
                                                                    COUNT(p.id) AS aantal_producten
                                                                FROM
                                                                    producten p,
                                                                    winkelmandje w
                                                                WHERE
                                                                    w.artikel_id = p.id
                                                                AND
                                                                    w.lid_id = ".$core->leden->info[mijn][id]."
                                                                GROUP BY
                                                                    p.id");
                        if($core->mysql->num_rows($winkelmandQuery) >= 1)
                        {
                            ?>
                            
                <div id=winkelmand>
                    <span>Op dit moment bevinden zich de volgende producten in uw winkelmandje:</span>
                  
                            <table width=700px border=0 cellpadding=0 cellspacing=0>
                            <tr>
                                <td class=table_top><b>Afbeelding:</b></td>
                                <td class=table_top><b>Productnaam:</b></td>
                                <td class=table_top><b>Aantal:</b></td>
                                <td class=table_top><b>Prijs:</b></td>
                            </tr>
                        [COLOR= #0000BB]<?php[/COLOR]
                            [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]mysql[COLOR= #007700]->[/COLOR]fetch[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandQuery[/COLOR][COLOR= #007700]))
                            {[/COLOR]
                                ?>  
                                <tr>
                                    <td><img src=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] _ROOT_[COLOR= #007700];[/COLOR] ?>images/producten/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding_klein[/COLOR][COLOR= #007700]]);[/COLOR] ?> alt= style=margin-left:40px; /></td>
                                    <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding_klein[/COLOR][COLOR= #007700]]));[/COLOR] ?></td>
                                    <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal_producten[/COLOR][COLOR= #007700]];[/COLOR] ?>x</td>
                                    <td class=table_right>&euro;[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prijs[/COLOR][COLOR= #007700]]);[/COLOR] ?></td>
                                </tr>
                                
                                [COLOR= #0000BB]<?php[/COLOR]
                            [COLOR= #007700]}[/COLOR]
                            ?>
                            </table>
                            [COLOR= #0000BB]<?php
                             $prijsQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]mysql[COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT
                                                                    p.prijs
                                                                FROM
                                                                    winkelmandje w,
                                                                    producten p
                                                                WHERE
                                                                    w.lid_id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]leden[COLOR= #007700]->[/COLOR]info[COLOR= #007700][[/COLOR][COLOR= #DD0000]mijn[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"
                                                                AND
                                                                    w.artikel_id = p.id"[/COLOR][COLOR= #007700]);[/COLOR]
                            [COLOR= #0000BB]$prijsFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]mysql[COLOR= #007700]->[/COLOR]fetch[COLOR= #007700]([/COLOR][COLOR= #0000BB]$prijsQuery[/COLOR][COLOR= #007700]);[/COLOR]
                                                                    ?>
                             
                            <div id=prijs>
                                <span>Totaal aantal producten:</span><span style=float:right;>1</span>
                                <span>Totaal bedrag:</span><span style=float:right;>&euro;[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$prijsFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prijs[/COLOR][COLOR= #007700]];[/COLOR]  ?></span>
                                <a href= class=button>verwijderen</a><a href= style=float: right; class=button>afrekenen</a></span>
                            </div>
                </div>


Gegroet
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik zou bovenaan $totaal = 0; neerzetten en dan steeds in die while $totaal += $winkelmandFetch[prijs];
Die $prijsQuery kan dan weg en op de plek van $prijsFetch[prijs] zet je dan $totaal neer biggrin
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heb nu dit, maar als ik dit doe dan weergeef hij de prijs gedeelte niet, dat gaat dan weg.

$totaal = 0;
       $winkelmandQuery = $core->mysql->query("SELECT
                                                                    p.naam,
                                                                    p.afbeelding_klein,
                                                                    p.prijs,
                                                                    COUNT(p.id) AS aantal_producten
                                                                FROM
                                                                    producten p,
                                                                    winkelmandje w
                                                                WHERE
                                                                    w.artikel_id = p.id
                                                                AND
                                                                    w.lid_id = ".$core->leden->info[mijn][id]."
                                                                GROUP BY
                                                                    p.id");
                        if($core->mysql->num_rows($winkelmandQuery) >= 1)
                        {
                            ?>
                            
                <div id=winkelmand>
                    <span>Op dit moment bevinden zich de volgende producten in uw winkelmandje:</span>
                  
                            <table width=700px border=0 cellpadding=0 cellspacing=0>
                            <tr>
                                <td class=table_top><b>Afbeelding:</b></td>
                                <td class=table_top><b>Productnaam:</b></td>
                                <td class=table_top><b>Aantal:</b></td>
                                <td class=table_top><b>Prijs:</b></td>
                            </tr>
                        [COLOR= #0000BB]<?php[/COLOR]
                            [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]mysql[COLOR= #007700]->[/COLOR]fetch[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandQuery[/COLOR][COLOR= #007700]))
                            {[/COLOR]
                                ?>  
                                <tr>
                                    <td><img src=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] _ROOT_[COLOR= #007700];[/COLOR] ?>images/producten/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding_klein[/COLOR][COLOR= #007700]]);[/COLOR] ?> alt= style=margin-left:40px; /></td>
                                    <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding_klein[/COLOR][COLOR= #007700]]));[/COLOR] ?></td>
                                    <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal_producten[/COLOR][COLOR= #007700]];[/COLOR] ?>x</td>
                                    <td class=table_right>&euro;[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prijs[/COLOR][COLOR= #007700]]);[/COLOR] ?></td>
                                </tr>
                                
                                [COLOR= #0000BB]<?php[/COLOR]
                            [COLOR= #007700]}[/COLOR]
                            ?>
                            </table>
                            [COLOR= #0000BB]<?php[/COLOR]
                            [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]+=[/COLOR] [COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prijs[/COLOR][COLOR= #007700]])
                            {[/COLOR]
                              ?>
                            
                            <div id=prijs>
                                <span>Totaal aantal producten:</span><span style=float:right;>1</span>
                                <span>Totaal bedrag:</span><span style=float:right;>&euro;[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$totaal[/COLOR][COLOR= #007700];[/COLOR]  ?></span>
                                <a href= class=button>verwijderen</a><a href= style=float: right; class=button>afrekenen</a></span>
                            </div>
                            [COLOR= #0000BB]<?php[/COLOR]
                            [COLOR= #007700]}[/COLOR]
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];
                        }[/COLOR]
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo bedoelde ik het niet emo
[COLOR= #0000BB]<?php
  $totaal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
       [COLOR= #0000BB]$winkelmandQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]mysql[COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT
                                                                    p.naam,
                                                                    p.afbeelding_klein,
                                                                    p.prijs,
                                                                    COUNT(p.id) AS aantal_producten
                                                                FROM
                                                                    producten p,
                                                                    winkelmandje w
                                                                WHERE
                                                                    w.artikel_id = p.id
                                                                AND
                                                                    w.lid_id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]leden[COLOR= #007700]->[/COLOR]info[COLOR= #007700][[/COLOR][COLOR= #DD0000]mijn[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"
                                                                GROUP BY
                                                                    p.id"[/COLOR][COLOR= #007700]);[/COLOR]
                        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]mysql[COLOR= #007700]->[/COLOR]num_rows[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandQuery[/COLOR][COLOR= #007700]) >=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
                        {[/COLOR]
                            ?>
                            
                <div id=winkelmand>
                    <span>Op dit moment bevinden zich de volgende producten in uw winkelmandje:</span>
                  
                            <table width=700px border=0 cellpadding=0 cellspacing=0>
                            <tr>
                                <td class=table_top><b>Afbeelding:</b></td>
                                <td class=table_top><b>Productnaam:</b></td>
                                <td class=table_top><b>Aantal:</b></td>
                                <td class=table_top><b>Prijs:</b></td>
                            </tr>
                        [COLOR= #0000BB]<?php[/COLOR]
                            [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]mysql[COLOR= #007700]->[/COLOR]fetch[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandQuery[/COLOR][COLOR= #007700]))
                            {[/COLOR]
                                [COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]+=[/COLOR] [COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prijs[/COLOR][COLOR= #007700]][/COLOR]
                                ?>  
                                <tr>
                                    <td><img src=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] _ROOT_[COLOR= #007700];[/COLOR] ?>images/producten/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding_klein[/COLOR][COLOR= #007700]]);[/COLOR] ?> alt= style=margin-left:40px; /></td>
                                    <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding_klein[/COLOR][COLOR= #007700]]));[/COLOR] ?></td>
                                    <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal_producten[/COLOR][COLOR= #007700]];[/COLOR] ?>x</td>
                                    <td class=table_right>&euro;[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]entities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$winkelmandFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prijs[/COLOR][COLOR= #007700]]);[/COLOR] ?></td>
                                </tr>
                                
                                [COLOR= #0000BB]<?php[/COLOR]
                            [COLOR= #007700]}[/COLOR]
                            ?>
                            </table>
                            <div id=prijs>
                                <span>Totaal aantal producten:</span><span style=float:right;>1</span>
                                <span>Totaal bedrag:</span><span style=float:right;>&euro;[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$totaal[/COLOR][COLOR= #007700];[/COLOR]  ?></span>
                                <a href= class=button>verwijderen</a><a href= style=float: right; class=button>afrekenen</a></span>
                            </div>
                            [COLOR= #0000BB]<?php[/COLOR]
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];
                        }[/COLOR]
?>
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oja, zo dom van me emo Maar nog bedankt he Luuk biggrin
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Graag gedaan biggrin
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Trouwens, als je 2 keer het zelfde product hebt, dan rekent hij alleen 1 uit maar niet meerde. Hoe zorg ik ervoor dat hij dan als je meerdere producten hebt dat hij die ook uitrekent.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$totaal += $winkelmandFetch[prijs]; veranderen in $totaal += $winkelmandFetch[aantal_producten] * $winkelmandFetch[prijs]
0
Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dankjewel Luuk biggrin
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren