Gegevens uit meerdere tabellen halen met while
Hoe kan ik met een while en mysql_fetch_assoc gegevens uit twee tabellen halen?
De tabellen zijn:
Ik gebruik nu
$huidigePagina = mysql_query("SELECT id,naam,email,bericht,datum,tijd,verberg FROM berichten ORDER BY id DESC LIMIT " . $reactiesPagina.",".$aantalReacties);
in combinatie met
while($geg = mysql_fetch_assoc($huidigePagina)){ ... }
Maarja ik weet niet hoe dat nu met twee tabellen moet.
De tabellen zijn:
Code (php)
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
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
CREATE TABLE IF NOT EXISTS `album_foto` (
`id` int(11) NOT NULL auto_increment,
`map_id` int(11) NOT NULL,
`titel` varchar(100) NOT NULL,
`locatie` varchar(500) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
CREATE TABLE IF NOT EXISTS `album_map` (
`id` int(11) NOT NULL auto_increment,
`naam` varchar(100) NOT NULL,
`locatie` varchar(500) NOT NULL,
`datumtijd` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
CREATE TABLE IF NOT EXISTS `album_reacties` (
`id` int(11) NOT NULL auto_increment,
`foto_id` int(11) NOT NULL,
`naam` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`bericht` text NOT NULL,
`ip` varchar(20) NOT NULL,
`datum` date NOT NULL,
`tijd` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
`id` int(11) NOT NULL auto_increment,
`map_id` int(11) NOT NULL,
`titel` varchar(100) NOT NULL,
`locatie` varchar(500) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
CREATE TABLE IF NOT EXISTS `album_map` (
`id` int(11) NOT NULL auto_increment,
`naam` varchar(100) NOT NULL,
`locatie` varchar(500) NOT NULL,
`datumtijd` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
CREATE TABLE IF NOT EXISTS `album_reacties` (
`id` int(11) NOT NULL auto_increment,
`foto_id` int(11) NOT NULL,
`naam` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`bericht` text NOT NULL,
`ip` varchar(20) NOT NULL,
`datum` date NOT NULL,
`tijd` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Ik gebruik nu
$huidigePagina = mysql_query("SELECT id,naam,email,bericht,datum,tijd,verberg FROM berichten ORDER BY id DESC LIMIT " . $reactiesPagina.",".$aantalReacties);
in combinatie met
while($geg = mysql_fetch_assoc($huidigePagina)){ ... }
Maarja ik weet niet hoe dat nu met twee tabellen moet.
Gesponsorde koppelingen:
Uhh een voorbeeldje



