Jump to content

Recommended Posts

Posted

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."

 

Posted

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

Posted

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>)';
	}

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.