har et lille problem med at hente info fra 2 tabler og derefter udskrive det.
CREATE TABLE `lastlogin` ( `ID` int(11) NOT NULL auto_increment, `user` varchar(50) NOT NULL default '', `logintime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), UNIQUE KEY `idx_brugere` (`user`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=1;
CREATE TABLE `login` ( `ID` int(11) NOT NULL auto_increment, `user` varchar(50) NOT NULL default '', `pass` varchar(25) NOT NULL default '', `lastseen` text NOT NULL, `lastlogin` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `online` text NOT NULL, `navn` varchar(51) NOT NULL default 'Ikke oplyst', `image` varchar(35) NOT NULL default 'gaest.jpg', `member` varchar(50) NOT NULL default 'Gæst', `email` varchar(50) NOT NULL default '', `adresse` text NOT NULL, `postnr` varchar(4) NOT NULL default '', `kommune` text NOT NULL, `mobil` varchar(8) NOT NULL default '', `foedselsdag` char(2) NOT NULL default '', `aar` varchar(4) NOT NULL default '', `maaned` varchar(14) NOT NULL default '', `tid` datetime NOT NULL default '0000-00-00 00:00:00', `oprettetaf` text NOT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `idx_brugere` (`user`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=1;
$antal = mysql_result(mysql_query("SELECT count(id) FROM lastlogin"),0);
$sql = mysql_query("SELECT id, user, logintime, date_format(logintime, '%e/%c %Y') AS nyDato, date_format(logintime, '%H:%i') AS nyTid FROM lastlogin ORDER by logintime DESC LIMIT $offset,$range"); $sql2 = mysql_query("SELECT id, email, navn, image, user, member, oprettetaf, date_format(tid, '%e/%c %Y, %H:%i') as tid FROM login WHERE id =".$row[id]."");
$sql = mysql_query("SELECT image, member, date_format(tid, '%e/%c %Y, %H:%i') as tid, oprettetaf, email, navn, user, date_format(logintime, '%e/%c %Y') AS nyDato, date_format(logintime, '%H:%i') AS nyTid FROM login INNER JOIN lastlogin ON id = id ORDER BY logintime $offset,$range");
SELECT l.image, l.member, date_format( l.tid, '%e/%c %Y, %H:%i' ) AS tid, l.oprettetaf, l.email, l.navn, l.user, date_format( ll.logintime, '%e/%c %Y' ) AS nyDato, date_format( ll.logintime, '%H:%i' ) AS nyTid FROM l.login INNER JOIN lastlogin ll ON l.id = ll.id ORDER BY ll.logintime DESC LIMIT $offset, $range LIMIT 0 , 30
MySQL returnerede: Dokumentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$offset , $range LIMIT 0, 30' at line 1
SELECT l.image, l.member, date_format(l.tid, '%e/%c %Y, %H:%i') as tid, l.oprettetaf, l.email, l.navn, l.user, date_format(ll.logintime, '%e/%c %Y') AS nyDato, date_format(ll.logintime, '%H:%i') AS nyTid FROM l.login INNER JOIN lastlogin ll ON l.id = ll.id ORDER BY ll.logintime DESC LIMIT $offset,$range
og fejlen er stadig
Fejl
SQL-forespørgsel: Dokumentation
SELECT l.image, l.member, date_format( l.tid, '%e/%c %Y, %H:%i' ) AS tid, l.oprettetaf, l.email, l.navn, l.user, date_format( ll.logintime, '%e/%c %Y' ) AS nyDato, date_format( ll.logintime, '%H:%i' ) AS nyTid FROM l.login INNER JOIN lastlogin ll ON l.id = ll.id ORDER BY ll.logintime DESC LIMIT $offset, $range LIMIT 0 , 30
MySQL returnerede: Dokumentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$offset , $range LIMIT 0, 30' at line 1
SELECT l.image, l.member, date_format(l.tid, '%e/%c %Y, %H:%i') as tid, l.oprettetaf, l.email, l.navn, l.user, date_format(ll.logintime, '%e/%c %Y') AS nyDato, date_format(ll.logintime, '%H:%i') AS nyTid FROM l.login INNER JOIN lastlogin ll ON l.id = ll.id ORDER BY ll.logintime DESC LIMIT LIMIT 0, 30
Fejl
SQL-forespørgsel:
l.image, l.member, date_format( l.tid, '%e/%c %Y, %H:%i' ) AS tid, l.oprettetaf, l.email, l.navn, l.user, date_format( ll.logintime, '%e/%c %Y' ) AS nyDato, date_format( ll.logintime, '%H:%i' ) AS nyTid FROM l.login INNER JOIN lastlogin ll ON l.id = ll.id ORDER BY ll.logintime DESC LIMIT LIMIT 0 , 30
MySQL returnerede: Dokumentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'l.image, l.member, date_format(l.tid, '%e/%c %Y, %H:%i') as tid, ' at line 1
SELECT l.image, l.member, date_format(l.tid, '%e/%c %Y, %H:%i') as tid, l.oprettetaf, l.email, l.navn, l.user, date_format(ll.logintime, '%e/%c %Y') AS nyDato, date_format(ll.logintime, '%H:%i') AS nyTid FROM login l INNER JOIN lastlogin ll ON l.id = ll.id ORDER BY ll.logintime DESC LIMIT 0,24
skal man så bare lave en
$sql = mysql_query("SELECT l.image, l.member, date_format(l.tid, '%e/%c %Y, %H:%i') as tid, l.oprettetaf, l.email, l.navn, l.user, date_format(ll.logintime, '%e/%c %Y') AS nyDato, date_format(ll.logintime, '%H:%i') AS nyTid FROM login 1 INNER JOIN lastlogin ll ON l.id = ll.id ORDER BY ll.logintime $offset,$range");
og sætte ind i scriptet hvad men værdier i offset og range når flere linier kommer til i login ??
Du har en fejl i linje 19. Ret lige til: echo (empty($row['l.image'])) ? '' : '<img src="files/'.$row['l.image'].'" class="image"><br>';
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.