Array vraag

Gestart doorMitchels6 reacties56 weergaven

7 berichten · pagina 1 van 1

Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb deze query:

[COLOR= #0000BB]<?
$settinqs[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM tabel"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$settinqs[/COLOR][COLOR= #007700])){[/COLOR]
    [COLOR= #0000BB]$settings[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]] =[/COLOR] [COLOR= #0000BB]$data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]waarde[/COLOR][COLOR= #007700]];
}[/COLOR]?>


Dan heb ik deze var:

[COLOR= #0000BB]<?
$aantallen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$settings[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantallen[/COLOR][COLOR= #007700]]);[/COLOR]
?>


De tabel:

CREATE TABLE IF NOT EXISTS `tabel` (
  `naam` varchar(255) NOT NULL,
  `waarde` varchar(256) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `tabel` (`naam`, `waarde`) VALUES
(aantallen, 1, 2, 3, 4, 5),


Ik wil dat de aantallen uit de database gehaald worden en werkend in een array geplaatst worden. Dat lukt nu niet.

Dit is mijn echo gedeelte:

<b>Aantal : </b><select name="aantal">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantallen[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++){[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<option value="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$aantallen[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$aantallen[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"</option>"[/COLOR][COLOR= #007700]; }[/COLOR] ?></select><br />
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$aantallen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$settings[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantallen[/COLOR][COLOR= #007700]]));[/COLOR]
?>
0
Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee, want dan krijg ik in mijn dropdown box array te staan.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$aantallen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$settings[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantallen[/COLOR][COLOR= #007700]]);[/COLOR]
?>
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
edit: Oeps, ik had dat array om de explode gelaten, lol. Het stond dus in een dubbele array emo
0
Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt Luuk & Sjoerd! smile
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Graag gedaan smile
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