raikm 0 Denunciar post Postado Novembro 4, 2008 bem estou criando um sistema de noticias e gostaria de saber como que eu posso colocar para aparecer apenas as 5 ultimas noticas postadas? Compartilhar este post Link para o post Compartilhar em outros sites
Pirata_ 0 Denunciar post Postado Novembro 4, 2008 na sua query use "ORDER BY id ASC LIMIT 5" Compartilhar este post Link para o post Compartilhar em outros sites
raikm 0 Denunciar post Postado Novembro 4, 2008 vlw amigo http://forum.imasters.com.br/public/style_emoticons/default/grin.gif brigadao Compartilhar este post Link para o post Compartilhar em outros sites
Mário Monteiro 179 Denunciar post Postado Novembro 5, 2008 no caso seria DESC para as ultimas ASC pegaria as primeiras Compartilhar este post Link para o post Compartilhar em outros sites
raikm 0 Denunciar post Postado Novembro 6, 2008 bem eu sou novato nisso entao help me o codigo é o seguinte mysql_select_db($database_conectar, $conectar); $query_Recordset1 = "SELECT * FROM noticias"; $Recordset1 = mysql_query($query_Recordset1, $conectar) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); eu preciso que apareca as 5 ultimas linhas inseridos na tabela Compartilhar este post Link para o post Compartilhar em outros sites
lucrod1 0 Denunciar post Postado Novembro 6, 2008 bem eu sou novato nisso entao help me o codigo é o seguinte mysql_select_db($database_conectar, $conectar); $query_Recordset1 = "SELECT * FROM noticias"; $Recordset1 = mysql_query($query_Recordset1, $conectar) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); eu preciso que apareca as 5 ultimas linhas inseridos na tabela mude essa linha para $query_Recordset1 = "SELECT * FROM noticias ORDER BY id desc LIMIT 5"; Compartilhar este post Link para o post Compartilhar em outros sites
raikm 0 Denunciar post Postado Novembro 7, 2008 po eu axo q meu server deve estar com algum problema eu fiz issu ai que tu falo e nao deu certo cacei em varios sites e todes q tentei nenhum funcionou =/ tipo eu fiz akilo ai pra botar pra aparecer ve se ta certo tipo ultima postagem <div id="assunto" >Assunto: <?php echo $row_Recordset1['assunto']; ?></div> ai pra penultima <div id="assunto1" >Assunto: <?php echo $row_Recordset1['assunto']; ?></div> talvez seja isso que eusteja errando Compartilhar este post Link para o post Compartilhar em outros sites
luciano antony 0 Denunciar post Postado Novembro 7, 2008 quais são os campos que sua tabela possue? Compartilhar este post Link para o post Compartilhar em outros sites
Mário Monteiro 179 Denunciar post Postado Novembro 7, 2008 nao esta dando certo como? Esta dando erro ou nao ocorre o que esperava apenas? Compartilhar este post Link para o post Compartilhar em outros sites
Alaerte Gabriel 662 Denunciar post Postado Novembro 7, 2008 Não da erro amigo, a falha ai é que você não está utilizando o laço de repetição while, com isso ele não vai listar as 5 notícias, deve ficar assim: <?php $query_Recordset1 = "SELECT * FROM noticias ORDER BY id DESC LIMIT 5"; $Recordset1 = mysql_query($query_Recordset1, $conectar) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); while($v=mysql_fetch_assoc($Recordset1)){ ?> <div id="assunto" >Assunto: <?php echo $row_Recordset1['assunto']; ?></div> <br /> <div id="assunto1" >Assunto: <?php echo $row_Recordset1['assunto']; ?></div> <?php } ?> Compartilhar este post Link para o post Compartilhar em outros sites
raikm 0 Denunciar post Postado Novembro 7, 2008 eu ainda nao consegui ja devo ta tirando a paciencia de voces mas olha só o problema é o seguinte eu cadastrei duas noticias no meu mysql entao mesmo sem colocar o DESC ou o ASC teria de aparecer as duas noticias certo? o meu só aparece uma, quando coloco o DESC aparece a ultima postada e quando coloco o ASC aparece a primeira vou colocar o codigo todo da pg se algum puder dar uma olhada <?php require_once('../Connections/conectar.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_conectar, $conectar); $query_Recordset1 = "SELECT * FROM noticias ORDER BY id DESC LIMIT 5"; $Recordset1 = mysql_query($query_Recordset1, $conectar) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div id="news"><img src="../img/post.gif" width="560" height="400" /></div> <div id="avatar"><img src="<?php echo $row_Recordset1['avatar']; ?>" width="100" height="100"/></div> <div id="data"> <div align="left"><?php echo $row_Recordset1['data']; ?></div> </div> <div id="assunto"> <div align="left">Assunto: <?php echo $row_Recordset1['assunto']; ?></div> </div> <div id="autor"> <div align="left">Postado por: <?php echo $row_Recordset1['autor']; ?></div> </div> <div id="texto" align="justify"><?php echo $row_Recordset1['texto']; ?></div> <div id="img1"><a href="<?php echo $row_Recordset1['img1']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img1']; ?>" width="80" height="80"/></a></div> <div id="img2"><a href="<?php echo $row_Recordset1['img2']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img2']; ?>" width="80" height="80"/></a></div> <div id="img3"><a href="<?php echo $row_Recordset1['img3']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img3']; ?>" width="80" height="80"/></a></div> <div id="img4"><a href="<?php echo $row_Recordset1['img4']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img4']; ?>" width="80" height="80"/></a></div> <div id="img5"><a href="<?php echo $row_Recordset1['img5']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img5']; ?>" width="80" height="80"/></a></div> <div id="img6"><a href="<?php echo $row_Recordset1['img6']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img6']; ?>" width="80" height="80"/></a></div> <!--home1--> <div id="news1"><img src="../img/post.gif" width="560" height="400" /></div> <div id="avatar1"><img src="<?php echo $row_Recordset1['avatar']; ?>" width="100" height="100"/></div> <div id="data1"> <div align="left"><?php echo $row_Recordset1['data']; ?></div> </div> <div id="assunto1"> <div align="left">Assunto: <?php echo $row_Recordset1['assunto']; ?></div> </div> <div id="autor1"> <div align="left">Postado por: <?php echo $row_Recordset1['autor']; ?></div> </div> <div id="texto1" align="justify"><?php echo $row_Recordset1['texto']; ?></div> <div id="img11"><a href="<?php echo $row_Recordset1['img1']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img1']; ?>" width="80" height="80"/></a></div> <div id="img21"><a href="<?php echo $row_Recordset1['img2']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img2']; ?>" width="80" height="80"/></a></div> <div id="img31"><a href="<?php echo $row_Recordset1['img3']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img3']; ?>" width="80" height="80"/></a></div> <div id="img41"><a href="<?php echo $row_Recordset1['img4']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img4']; ?>" width="80" height="80"/></a></div> <div id="img51"><a href="<?php echo $row_Recordset1['img5']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img5']; ?>" width="80" height="80"/></a><a href="<?php echo $row_Recordset1['img5']; ?>" target="_blank"></a></div> <div id="img61"><a href="<?php echo $row_Recordset1['img6']; ?>" target="_blank"><img src="<?php echo $row_Recordset1['img6']; ?>" width="80" height="80"/></a><a href="<?php echo $row_Recordset1['img6']; ?>" target="_blank"></a></div> </body> </html><?php mysql_free_result($Recordset1); ?> acho q nao é necessario colocar o css né bem agradeco a todos que estao ajudando e se puder ajudar mais vou agracecer mais http://forum.imasters.com.br/public/style_emoticons/default/grin.gif Compartilhar este post Link para o post Compartilhar em outros sites
raikm 0 Denunciar post Postado Novembro 7, 2008 ou se alguem kiser pode me indicar uma apostila ou tutorial eu irei aceitar pq o q eu kero é aprender Compartilhar este post Link para o post Compartilhar em outros sites