Raar php probleem

Gestart doorFreestyle8 reacties39 weergaven

9 berichten · pagina 1 van 1

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik wil een paar gegevens op halen met while uit mijn database. Maar hij haalt er maar een op. Terwijl er 2 in de database staan.

Code:

[COLOR= #0000BB]<?php
$bsql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT id, manier, procent, bedrag FROM optie LIMIT 0,10"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$bquery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bsql[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]bquery: [/COLOR][COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$bfetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bquery[/COLOR][COLOR= #007700]);[/COLOR]
?>
<table border="1px" cellspacing="0" cellpadding="4px;">
    <tr>
        <td>Betaal optie:</td>
        [COLOR= #0000BB]<?php[/COLOR] 
        [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$brij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bquery[/COLOR][COLOR= #007700])) {[/COLOR] 
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<td>[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$brij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]manier[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]</td>[/COLOR][COLOR= #007700];
        }[/COLOR] ?>
    </tr>
</table>


Wat heb ik hier fout??
Alvast bedankt!
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Haal $bfetch weg en doe in de while:

while($row = mysql_fetch_assoc($bquery))
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het werkt (heb alleen $bfetch) weg gehaald.
Bedankt!!
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Geen probleem!

Het klopt inderdaad dat het door alleen $bfetch weg te halen ook werkt, maar ik vind persoonlijk mysql_fetch_assoc(); beter dan mysql_fetch_array();
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Josnl schreef:
Geen probleem!

Het klopt inderdaad dat het door alleen $bfetch weg te halen ook werkt, maar ik vind persoonlijk mysql_fetch_assoc(); beter dan mysql_fetch_array();
array moet toch bij een whilebloos??
Of echt alleen bij een array?
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee hoor, array hoeft niet per se bij een while, ik gebruik namelijk altijd mysql_fetch_assoc(); wink
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Josnl schreef:
Nee hoor, array hoeft niet per se bij een while, ik gebruik namelijk altijd mysql_fetch_assoc(); wink
Ik normaal eigenlijk ook.

En weet jij miss ook waarom ik de andere whiles niet doen??

<tr>
        <td>Betaal optie:</td>
        [COLOR= #0000BB]<?php[/COLOR] 
        [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$brij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bquery[/COLOR][COLOR= #007700])) {[/COLOR] 
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<td>[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$brij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]manier[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]</td>[/COLOR][COLOR= #007700];
        }[/COLOR] ?>
    </tr>
    <tr>
        <td>Extra kosten (procenten):</td>
        [COLOR= #0000BB]<?php[/COLOR] 
        [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$prij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bquery[/COLOR][COLOR= #007700])) {[/COLOR] 
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<td>[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$prij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]procent[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]%</td>[/COLOR][COLOR= #007700];
        }[/COLOR] ?>
    </tr>
    <tr>
        <td>Extra kosten (vast bedrag):</td>
        [COLOR= #0000BB]<?php[/COLOR] 
        [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$grij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bquery[/COLOR][COLOR= #007700])) {[/COLOR] 
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<td>&euro;[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$grij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bedrag[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]%</td>[/COLOR][COLOR= #007700];
        }[/COLOR] ?>
    </tr>
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Geen idee waarom die niet werkt, maar het is niet echt heel handig om voor elk onderdeel een nieuwe while aan te maken, kan net zo goed in 1 while met 1 echo wink
PS: Verander dan ook gelijk mysql_fetch_array(); in mysql_fetch_assoc(); smile
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Josnl schreef:
Geen idee waarom die niet werkt, maar het is niet echt heel handig om voor elk onderdeel een nieuwe while aan te maken, kan net zo goed in 1 while met 1 echo wink
PS: Verander dan ook gelijk mysql_fetch_array(); in mysql_fetch_assoc(); smile
ooja, maar als ik het in een while zet kan het niet. Want dan komen er te veel enters en het moet steeds naast elkaar.

Moet je misschien steeds een nieuwe query hebben? Want als ik die bovenste weg doe dan doet die 2de het wel.
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