Bienvenido a datoweb.com!! En este foro podrás encontrar ayuda sobre diseño y desarrollo web en general. Si quieres formar parte de esta comunidad para pedir ayuda o colaborar ayudando a otros usuarios del foro solo tienes que registrarte desde el siguiente enlace: Registrarse en el Foro

Problema al pasar de la pagina post a ver los post

Buenas, tengo un problemilla, cuando hago click en el titulo de un post en mi pagina para ver el post entero, me salta al primero que puse, te pongo los dos codigos de las dos paginas a ver si me puedes echar una mano. gracias

Este es donde tengo todos los posts:
<?php require_once('Connections/conexion.php'); ?>

<!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">
<link href="skins/default/css/estilos.css" rel="stylesheet" type="text/css" />

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div id="wrapper">
  <div id="head">
    <div id="logo"><img src="skins/default/img/foto_principal.png" width="250" height="110" alt="logo" /></div>
    <div id="redes"><table width="116" border="0">
  <tr>
    <td width="22"><a href="https://www.facebook.com/TheCyclingExperienceCompany" target="_blank"><img src="skins/default/img/redsocial/img-facebook.png" width="22" height="23" alt="facebook" /></a></td>
    <td width="22"><a href="https://www.youtube.com" target="_blank"><img src="skins/default/img/redsocial/img-youtube.png" width="22" height="23" alt="youtube" /></a></td>
    <td width="22"><a href="https://vimeo.com/commencal" target="_blank"><img src="skins/default/img/redsocial/img-vimeo.png" width="22" height="22" alt="vimeo" /></a></td>
    <td width="22"><a href="https://twitter.com/" target="_blank"><img src="skins/default/img/redsocial/img-twitter.png" width="22" height="22" alt="twitter" /></a></td>
  </tr>
</table>    
    </div></div>
    <?php include("inc/usuario.php"); ?>
    <div id="buscador">
     <?php include("inc/buscador.php"); ?>
    
    </div>
</div>
  <div id="menu">
    <?php include("inc/menu.php"); ?>
  </div>
  <div id="cuerpo">
      <table width="99%">
  <tr width="70%">
    <td>
    <div id="textoposts">
       <?php include("inc/listado.php"); ?>
    </div></td>
    <td align="right" valign="top">
    <a href="agregar.php">AGREGAR POST</a>
    </td>
  </tr>
</table></div>
  
  <div id="footer">
    <?php include("inc/footer.php"); ?>
  </div>
</div>
</body>
</html>
Y este donde sale para ver el post entero:
PHP
<?php require_once('Connections/conexion.php'); 

mysql_select_db($database_conexion, $conexion);
$query_VerPost = "SELECT * FROM j_post";
$VerPost = mysql_query($query_VerPost, $conexion) or die(mysql_error());
$row_VerPost = mysql_fetch_assoc($VerPost);
$totalRows_VerPost = mysql_num_rows($VerPost);
 require_once('Connections/conexion.php'); 

?>

<!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">
<link href="skins/default/css/estilos.css" rel="stylesheet" type="text/css" />
<style type="text/css">
a:link {
    color: #D5FF53;
}
a:visited {
    color: #D5FF53;
}
a:hover {
    color: #F60;
}
a:active {
    color: #D5FF53;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $row_VerPost['titulo']; ?></title>
<meta name="description" content="<?php echo $row_VerPost['descripcion']; ?>" />
<meta name="keywords" content="<?php echo $row_VerPost['keywords']; ?>" />
</head>

<body>
<div id="wrapper">
  <div id="head">
    <div id="logo"><img src="skins/default/img/foto_principal.png" width="250" height="110" alt="logo" /></div>
    <div id="redes"><table width="116" border="0">
  <tr>
    <td width="22"><a href="https://www.facebook.com/TheCyclingExperienceCompany" target="_blank"><img src="skins/default/img/redsocial/img-facebook.png" width="22" height="23" alt="facebook" /></a></td>
    <td width="22"><a href="https://www.youtube.com" target="_blank"><img src="skins/default/img/redsocial/img-youtube.png" width="22" height="23" alt="youtube" /></a></td>
    <td width="22"><a href="https://vimeo.com/commencal" target="_blank"><img src="skins/default/img/redsocial/img-vimeo.png" width="22" height="22" alt="vimeo" /></a></td>
    <td width="22"><a href="https://twitter.com/" target="_blank"><img src="skins/default/img/redsocial/img-twitter.png" width="22" height="22" alt="twitter" /></a></td>
  </tr>
</table>    
    </div>
    <?php include("inc/usuario.php"); ?>
    <div id="buscador">
     <?php include("inc/buscador.php"); ?>
    </div>
  </div>
  <div id="menu">
    <?php include("inc/menu.php"); ?>
  </div>
  <div id="cuerpo">
      <div id="textoverpost">
     <div id="post_global">
            <div id="title_post"><?php echo $row_VerPost['titulo']; ?> </div>
        <div id="contenido_post">
              <?php echo $row_VerPost['mensajes']; ?></div>
            <div id="autor_post"><table width="100%" border="0">
              <tr>
                <td width="135" align="left"><img src="users/avatar/<?php echo sacaravatar ($row_VerPost['autor']); ?>" width="70" height="70" /></td>
                <td width="197"><?php echo sacarnombre ($row_VerPost['autor']); ?></td>
                <td width="324" align="right"><span style ="font-size:12px"><?php echo $row_VerPost['fecha']; ?></span></td>
            </tr>
              </table>
        </div>
      </div>
  </div>
  </div>
  
  <div id="footer">
    <?php include("inc/footer.php"); ?>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($VerPost);
?>
0
Puntos
1323
Visitas
3
Resp
Por jlasvignes hace 129 meses
Principiante
Respuesta #1
en principio veo que estas teniendo un fallo en el select de SQL mira tu tienes
mysql_select_db($database_conexion, $conexion);
$query_VerPost = "SELECT * FROM j_post";
$VerPost = mysql_query($query_VerPost, $conexion) or die(mysql_error());
$row_VerPost = mysql_fetch_assoc($VerPost);
$totalRows_VerPost = mysql_num_rows($VerPost);
 require_once('Connections/conexion.php');
osea un select * seleccionamelo todo y por eso te saca el primero debes de poner un WHERE osea seleciona todo donde la id es la del post algo asi
mysql_select_db($database_conexion, $conexion);
$query_VerPost = "SELECT * FROM j_post WHERE idpost=%s";
$VerPost = mysql_query($query_VerPost, $conexion) or die(mysql_error());
$row_VerPost = mysql_fetch_assoc($VerPost);
$totalRows_VerPost = mysql_num_rows($VerPost);
 require_once('Connections/conexion.php');
ponme el código del listado.php anda que es dede ayi donde mandas la ip del post
0
Puntos
Por zeuskx hace 129 meses
Administrador Sitio web
Respuesta #2
Aqui te paso el codigo de listado.php:
<?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_SacarPostHome = 2;
$pageNum_SacarPostHome = 0;
if (isset($_GET['pageNum_SacarPostHome'])) {
  $pageNum_SacarPostHome = $_GET['pageNum_SacarPostHome'];
}
$startRow_SacarPostHome = $pageNum_SacarPostHome * $maxRows_SacarPostHome;

mysql_select_db($database_conexion, $conexion);
$query_SacarPostHome = "SELECT * FROM j_post ORDER BY j_post.id DESC";
$query_limit_SacarPostHome = sprintf("%s LIMIT %d, %d", $query_SacarPostHome, $startRow_SacarPostHome, $maxRows_SacarPostHome);
$SacarPostHome = mysql_query($query_limit_SacarPostHome, $conexion) or die(mysql_error());
$row_SacarPostHome = mysql_fetch_assoc($SacarPostHome);

if (isset($_GET['totalRows_SacarPostHome'])) {
  $totalRows_SacarPostHome = $_GET['totalRows_SacarPostHome'];
} else {
  $all_SacarPostHome = mysql_query($query_SacarPostHome);
  $totalRows_SacarPostHome = mysql_num_rows($all_SacarPostHome);
}
$totalPages_SacarPostHome = ceil($totalRows_SacarPostHome/$maxRows_SacarPostHome)-1;

$queryString_SacarPostHome = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_SacarPostHome") == false && 
        stristr($param, "totalRows_SacarPostHome") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_SacarPostHome = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_SacarPostHome = sprintf("&totalRows_SacarPostHome=%d%s", $totalRows_SacarPostHome, $queryString_SacarPostHome);
?>

<?php if ($row_SacarPostHome =="") {
    echo "Aun no han comentado nada, se tu el primero";
}
else {    
    
    ?>
 <?php do { ?>
          <div id="post_global">
            <div id="title_post"><a href="verpost.php?recordID=<?php echo $row_SacarPostHome['id']; ?>"><?php echo $row_SacarPostHome['titulo']; ?></a> </div>
            <div id="contenido_post">
          
          <?php $contenidocorto=($row_SacarPostHome['mensajes']);
          if ((strlen ($contenidocorto))> 60) { $contenidocorto=substr($contenidocorto, 0, 500); }
              echo $contenidocorto;?>
         
            </div>
            <div id="autor_post"><table width="100%" border="0">
              <tr>
                <td width="135" align="left"><img src="users/avatar/<?php echo sacaravatar($row_SacarPostHome ["autor"]); ?>" width="70" height="70" /></td>
                <td width="197"><?php echo sacarnombre ($row_SacarPostHome['autor']); ?></td>
                <td width="324" align="right"><span style ="font-size:12px"><?php echo $row_SacarPostHome['fecha']; ?></span></td>
                </tr>
              </table>
              </div>
          </div>
  <table border="0" align="right">
          <tr>
            <td><?php if ($pageNum_SacarPostHome > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_SacarPostHome=%d%s", $currentPage, max(0, $pageNum_SacarPostHome - 1), $queryString_SacarPostHome); ?>">Previous</a>
                <?php } // Show if not first page ?></td>
            <td><?php if ($pageNum_SacarPostHome < $totalPages_SacarPostHome) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_SacarPostHome=%d%s", $currentPage, min($totalPages_SacarPostHome, $pageNum_SacarPostHome + 1), $queryString_SacarPostHome); ?>">Next</a>
                <?php } // Show if not last page ?></td>
          </tr>
  </table>
  <?php } while ($row_SacarPostHome = mysql_fetch_assoc($SacarPostHome)); ?>

<?php }?>
<?php
mysql_free_result($SacarPostHome);
?>
0
Puntos
Por jlasvignes hace 129 meses
Principiante
Respuesta #3
vale el listado esta bien el la pagina verpost la que esta mal mira cambia esto
<?php require_once('Connections/conexion.php'); 

mysql_select_db($database_conexion, $conexion);
$query_VerPost = "SELECT * FROM j_post";
$VerPost = mysql_query($query_VerPost, $conexion) or die(mysql_error());
$row_VerPost = mysql_fetch_assoc($VerPost);
$totalRows_VerPost = mysql_num_rows($VerPost);
 require_once('Connections/conexion.php'); 

?>
por esto
<?php require_once('Connections/conexion.php'); 


$varfiltoPost_FiltramePost= $_GET["recordID"];

mysql_select_db($database_conexion, $conexion);
$query_VerPost = sprintf ("SELECT * FROM j_post WHERE j_post.id = %s", GetSQLValueString($varfiltoPost_FiltramePost, "int"));
$VerPost = mysql_query($query_VerPost, $conexion) or die(mysql_error());
$row_VerPost = mysql_fetch_assoc($VerPost);
$totalRows_VerPost = mysql_num_rows($VerPost);

?>
de todas formas ya que tienes el video descargado vuelvelo a mirar por que la consulta en los videos se hace correctamente un saludo amigo!
0
Puntos
Por zeuskx hace 129 meses
Administrador Sitio web
Compartir en facebook
Compartir en twitter
Compartir
Para comentar Inicia sesión o Registrate