webdesign 1 Denunciar post Postado Março 16, 2012 boas tenho este codigo,agora como faço para incluir na pagina principal ultimos 5 comentarios o codigo é este <?php if (isset($_POST['texto'])) { $texto = $_POST['texto']; $idNot = $_POST['id']; // vindo do campo hidden $insert = mysql_query( "INSERT INTO comentario (idNoticia, texto)VALUES ($idNot, '$texto')"); if($insert) echo '<script>alert("Sucesso no cadastro");</script>'; else echo '<script>alert("O comentario nao pode ser inserido!");</script>'; } ?> <?php ///////// noticias listada $tabela = 'up_posts'; $sql = "SELECT * FROM `$tabela` WHERE id = " . $_GET['id']; //get id e o ID da noticia principal $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo '<h1>', $row['nome'], '</h1>'; } unset($result, $row); //////cometarios $tabela = 'comentario'; $sql = "SELECT * FROM `$tabela` WHERE idNoticia = " . $_GET['id']; $result = mysql_query($sql) or die(mysql_error()); ?> <div style="background-color: greenyellow"><h2>Comentarios</h2> <?php while ($row = mysql_fetch_assoc($result)) { echo '<span style="background-color: #FFF; margin:50px;">', $row['texto'], '</span><br /><br />'; } ?> </div> <div><h2>Adicionar comentario</h2></div> <form name="form1" action="" method="POST"> <label>Sua MEnsagem</label> <textarea name="texto" rows="4" cols="20"> </textarea> <input type="hidden" name="id" value="<?php echo $_GET['id'] ?>" /> <input type="submit" value="Enviar" /> </form> <?php mysql_free_result($result); ?> Compartilhar este post Link para o post Compartilhar em outros sites
rfps888 7 Denunciar post Postado Março 16, 2012 Tens de fazer uma query á base de dados ordenada de forma decrescente com limit 5: $query = mysql_query("SELECT * FROM comentarios ORDER BY id DESC LIMIT 5"); Compartilhar este post Link para o post Compartilhar em outros sites
webdesign 1 Denunciar post Postado Março 16, 2012 agora como faço para colocar os resultados,na pagina inicial!? e em relação ao htacess como faço para resolver aquela situaçao do google eu tenho assim max axu que nao funca RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?topicos=nav/single&topico=$1 filmesanimados.net63.net/index.php?topicos=nav/single&topico=55&id=55 Compartilhar este post Link para o post Compartilhar em outros sites
rfps888 7 Denunciar post Postado Março 16, 2012 Estas a usar alguma framework? Compartilhar este post Link para o post Compartilhar em outros sites
webdesign 1 Denunciar post Postado Março 16, 2012 Estas a usar alguma framework? nao achu que nao,mas nem sequer sei o que é issu Compartilhar este post Link para o post Compartilhar em outros sites
rfps888 7 Denunciar post Postado Março 16, 2012 uma framework é tal como diz o nome, uma base de trabalho, ou seja é uma ferramenta que já faz as acções usuais para a elaboração de um website. Existem várias no mercado, Symphony, CodeIgniter, Kohana... É que não percebo porque a tua url é "index.php?topicos=nav/single&topico=55&id=55". Porque estas a mandar para o index? e o que é a variavel topicos? Compartilhar este post Link para o post Compartilhar em outros sites
webdesign 1 Denunciar post Postado Março 16, 2012 uma framework é tal como diz o nome, uma base de trabalho, ou seja é uma ferramenta que já faz as acções usuais para a elaboração de um website. Existem várias no mercado, Symphony, CodeIgniter, Kohana... É que não percebo porque a tua url é "index.php?topicos=nav/single&topico=55&id=55". Porque estas a mandar para o index? e o que é a variavel topicos? nao tenho nehuma framework instalada..eu tenho este codigo elaborado <?php include"header.php";?> <?php foreach ($_REQUEST as $___opt => $___val) { $$___opt = $___val; } if(empty($topicos)) { include("nav/home.php"); } elseif(substr($topicos, 0, 4)=='http' or substr($topicos, 0, 1)=="/" or substr($topicos, 0, 1)==".") { echo '<br><font face=arial size=11px><br><b>A página não existe.</b><br>Por favor selecione uma página a partir do Menu Principal.</font>'; } else { include("$topicos.php"); } ?> <?php include"footer.php";?> ña pagina index.php Compartilhar este post Link para o post Compartilhar em outros sites
rfps888 7 Denunciar post Postado Março 16, 2012 porque é que nao tens a chamar directo a página que queres então? por exemplo, queres ver o detalhe de uma noticia, no link para essa noticia em vez do: index.php?topicos=nav/single&topico=55&id=55 por que não colocas: noticia.php?id=55 assim ao clicar neste link ia directo para a página das noticias sem passar nenhum path na url como estas a fazer. Basicamente é criares outra página similar ao index mas com outro conteudo: <?php include "header.php"; //codigo da pagina de noticia include "footer.php"; Se estiver assim é mais simples fazer url friendly. Compartilhar este post Link para o post Compartilhar em outros sites
webdesign 1 Denunciar post Postado Março 16, 2012 <?php require_once('Connections/config.php'); ?><?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['login'])) { $loginUsername=$_POST['login']; $password=$_POST['senha']; $MM_fldUserAuthorization = "nivel"; $MM_redirectLoginSuccess = "admin/painel.php"; $MM_redirectLoginFailed = "admin/index.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_config, $config); $LoginRS__query=sprintf("SELECT usuario, senha, nivel FROM up_users WHERE usuario=%s AND senha=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $config) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'nivel'); //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!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 name="description" content="filmes animados,antigos trailers e críticas.tudo sobre desenhos animados.as últimas notícias no mundo do cinema." /> <meta name="keywords" content="filmes no,cinema,estreias,cartaz,trailer,desenhos animados,animação" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-28468674-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <?php include"Connections/config.php"; $conexao = mysql_connect("$hostname_config", "$username_config", "$password_config") or die(mysql_error()); $db = mysql_select_db("$database_config") or die(mysql_error()); ?> <?php include"scripts/limita_palavras.php"; ?> <?php $pgatual = strtolower(end(explode('/', $_GET[topicos]))); ?> <?php include"scripts.php";?> <?php $topico = $_GET['topico']; $noticias = mysql_query("SELECT thumb, titulo, texto, categoria, `data`, autor, valor_real, valor_pagseguro, visitas FROM up_posts WHERE titulo = '$topico'") or die(mysql_error()); if(@mysql_num_rows($noticias) <= '0'){ echo "$info_not"; }else{ $numero = '0'; while($res_noticias=mysql_fetch_array($noticias)){ $thumb = $res_noticias[0]; $titulo = $res_noticias[1]; $texto = $res_noticias[2]; $categoria = $res_noticias[3]; $data = $res_noticias[4]; $autor = $res_noticias[5]; $valor_real = $res_noticias[6]; $valor_pagseguro = $res_noticias[7]; $visitas = $res_noticias[8]; $numero++; $add_visita = $visitas + 1; $up_visitas = mysql_query("UPDATE up_posts SET visitas = '$add_visita', data = '$data' WHERE id = '$topico'") or die(mysql_error()); $pega_autor = mysql_query("SELECT nome FROM up_users WHERE id = '$autor'") or die(mysql_error()); if(@mysql_num_rows($pega_autor) <= '0') echo 'Erro ao selecionar o usuario'; else{ while($res_autor=mysql_fetch_array($pega_autor)){ $autor_do_post = $res_autor[0]; } } } } ?> <title> <?php print $titulo;?> filmesanimados </title> <!--meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /--> <link rel="shortcut icon" href="/favicon.ico" /> <link href="css/design.css" rel="stylesheet" type="text/css" /> <!--[if gt IE 8]> <link rel="stylesheet" href="css/ie.css" type="text/css" media="screen" /> <![endif] /--> <link href="scripts/shadowbox/shadowbox.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <div id="logo"> <div class="logo"> <h1><a title="logo de filmesanimados" href="index.php?topicos=nav/home">filmesanimados - Filmes animados antigos,desenhos animados,animação</a></h1> </div> <div id="header_busca"> <div class="busca_header"> <form name="search" action="index.php?topicos=nav/search" method="post"> <input type="text" name="pesquisa" /> <input type="submit" name="Encontre" value="Encontre" class="search_btn" /> </form> </div> </div><!--#header_busca--> </div><!--#logo--> <div id="menu"><!--Div container do Menu (Abaixo os itens originais do site + alguns adicionados Agora[os sem descrição])--> <ul id="mnprincipal"> <!-- Item do link pra Pg Inicial deve receber uma classe de ON especial! >> mn_on_inicial --> <li><a href="index.php?topicos=nav/home"><img src="images/estrutura/ic_index.gif" alt="Ic index"/></a></li> <li><a title="saiba tudo sobre seus filmes favoritos" href="#">Filmes</a> <ul> <li><a href="index.php?topicos=nav/page&pagina=ineditos">inéditos</a></li> <li><a href="#">estreia</a></li> <li><a href="#">em cartaz</a></li> <li><a href="#">gênero</a></li> <li><a href="#">Trailers</a></li> <li><a href="index.php?topicos=nav/contato">Contacto</a></li> </ul> </li> </ul> </div><!--container menu--> </div><!--#header--> <div id="contentbody"> assim já tenho que mudar contacto index.php?topicos=nav/contato home index.php?topicos=nav/home o que coloco aqui para mudar e pode me exemplificar como faço index.php eu na pasta nav tenho single.php que apresenta as noticias o search php ,categoria.php,comentarios.php.home.php.. axu que assim vai ser dificil entender mas nao custa tentar eu fiz assim na pagina index.php ~<?php include"header.php";?> <?php include("nav/home.php"); ?> <?php include"footer.php";?> ms ele apresenta a pagina inicial mas nao abre Compartilhar este post Link para o post Compartilhar em outros sites
rfps888 7 Denunciar post Postado Março 16, 2012 a ideia é essa que colocaste, mas não aparece nada se colocares assim? <?php include"header.php"; include("nav/home.php"); nclude"footer.php"; ?> Compartilhar este post Link para o post Compartilhar em outros sites
webdesign 1 Denunciar post Postado Março 16, 2012 a ideia é essa que colocaste, mas não aparece nada se colocares assim? <?php include"header.php"; include("nav/home.php"); nclude"footer.php"; ?> aparece tudo na pagina principal mas quando clicas já nao dá nada nem abre nada. nao tenho que alterar nada na url index.php?topicos=nav/single&topico=<?php echo $id; ?>&id=<?php echo $id; ?> Compartilhar este post Link para o post Compartilhar em outros sites
rfps888 7 Denunciar post Postado Março 16, 2012 tens de trocar, por exemplo na pagina das noticias, ou seja o detalhe da noticia seria: Ficheiro noticia.php <?php include "header.php"; include("nav/single.php"); include"footer.php"; ?> e a url: noticia.php?topico=<?php echo $id; ?>&id=<?php echo $id; ?> O ideal é conseguires tirar tambem o topico, os dois parametros da url sao id e não faz sentido, deveria ficar so o id noticia.php?id=<?php echo $id; ?> Compartilhar este post Link para o post Compartilhar em outros sites
webdesign 1 Denunciar post Postado Março 16, 2012 tens de trocar, por exemplo na pagina das noticias, ou seja o detalhe da noticia seria: Ficheiro noticia.php <?php include "header.php"; include("nav/single.php"); include"footer.php"; ?> e a url: noticia.php?topico=<?php echo $id; ?>&id=<?php echo $id; ?> O ideal é conseguires tirar tambem o topico, os dois parametros da url sao id e não faz sentido, deveria ficar so o id noticia.php?id=<?php echo $id; ?> vou experimentar,mais logo agora vou workar e obigadao Compartilhar este post Link para o post Compartilhar em outros sites