joninho Posted May 13, 2006 at 11:05 PM Report #27305 Posted May 13, 2006 at 11:05 PM Boas pessoal não há nenhuma query que apresente os ultimos 5 dados inseridos na tabela? Cumps [glow=red,2,300]Joninho[/glow]
QuickFire Posted May 13, 2006 at 11:16 PM Report #27307 Posted May 13, 2006 at 11:16 PM SELECT * from ´tabela´ LIMIT 5 ORDER by ´íd´ desc Tens é que ter um id ou uma date que dê um numero a cada row 🙂
joninho Posted May 13, 2006 at 11:16 PM Author Report #27308 Posted May 13, 2006 at 11:16 PM SELECT * from ´tabela´ LIMIT 5 ORDER by ´íd´ desc Tens é que ter um id ou uma date que dê um numero a cada row 🙂 Thnks... 🙂
M6 Posted May 14, 2006 at 11:02 AM Report #27341 Posted May 14, 2006 at 11:02 AM Esse tipo de problem é normalmente resolvido com uma coluna com um timestamp que é preenchido automaticamente pelo sistema a cada insersão (ou actualização) e fazes a ordenação por esse campo. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar."
joninho Posted May 17, 2006 at 07:08 PM Author Report #27925 Posted May 17, 2006 at 07:08 PM SELECT * from ´tabela´ LIMIT 5 ORDER by ´íd´ desc Tens é que ter um id ou uma date que dê um numero a cada row 👍 este código dá as 5 últimas rows... agora o que eu quero é ultima row = $noticia5 , penultima $noticia4 ... precebes? é para pôr aqui: www.freemind.vipsite.be EDIT: e deu-me erro o codigo que me deste Error SQL query: SELECT * FROM ´Noticias´ LIMIT 5 ORDER BY ´íd´ DESC LIMIT 0 , 30 MySQL said: #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 'ORDER by ´íd´ desc LIMIT 0, 30' at line 1
joninho Posted May 17, 2006 at 08:35 PM Author Report #27932 Posted May 17, 2006 at 08:35 PM Obrigado a todos, mas já descobri, aqui fica a solução que eu arranjei exemplo $noticia4 e $noticia5 //4 $noticia4="SELECT * FROM `Noticias` ORDER BY `id` DESC LIMIT 1 , 2 "; $noticia4=mysql_query($noticia4); while ($lol = mysql_fetch_row($noticia4)){ echo '<a href=index.php?action=Noticias&bin="'.$lol[0].'">'.$lol[2].'</a>(<h5>'.$lol[4].'</h5>)'; } echo "<br>"; //5 $noticia5="SELECT * FROM `Noticias` ORDER BY `id` DESC LIMIT 0 , 1 "; $noticia5=mysql_query($noticia5); while ($lol = mysql_fetch_row($noticia5)){ echo '<a href=index.php?action=Noticias&bin="'.$lol[0].'">'.$lol[2].'</a>(<h5>'.$lol[4].'</h5>)'; }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now