Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/12/2012, 16:09
leites25
 
Fecha de Ingreso: enero-2012
Mensajes: 5
Antigüedad: 12 años, 3 meses
Puntos: 0
Como crear respuestas para un foro

Hola amigos estoy creando un foro, mas que nada para practicar y para ver cuando me encuentro con trabas y pedir ayuda y luego aprender sobre lo que no sabia y el tema es el siguiente, yo tengo el foro no, creo las entradas y quiero que en esas entradas se puedan responder, como un foro normal.. Como podria hacerlo?

Estos son los codigos que estoy usando


Código HTML:
-- 
-- Base de datos: `codigos` 
-- 

-- -------------------------------------------------------- 

-- 
-- Estructura de tabla para la tabla `foro` 
-- 

CREATE TABLE IF NOT EXISTS `foro` ( 
  `id` int(7) NOT NULL AUTO_INCREMENT, 
  `autor` varchar(200) NOT NULL DEFAULT '', 
  `titulo` varchar(200) NOT NULL DEFAULT '', 
  `mensaje` text NOT NULL, 
  `fecha` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
  `respuestas` int(11) NOT NULL DEFAULT '0', 
  `identificador` int(7) NOT NULL DEFAULT '0', 
  `ult_respuesta` datetime DEFAULT NULL, 
  KEY `id` (`id`) 
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; 

-- 
-- Volcado de datos para la tabla `foro` 
-- 

INSERT INTO `foro` (`id`, `autor`, `titulo`, `mensaje`, `fecha`, `respuestas`, `identificador`, `ult_respuesta`) VALUES
(1, 'LeitesZeke', 'Primer Post', 'Este es el primer post de nuestro foro', '2012-12-18 13:48:32', 0, 0, NULL), 
(2, 'YumaTsukumo', 'Probando', 'Este es el segundo post', '2012-12-18 13:56:46', 0, 0, NULL), 
(3, 'LeitesZeke', 'asdasd', 'asdasdasd', '2012-12-18 15:12:15', 0, 0, NULL); 
index.php
Código HTML:
<?php 
    session_start(); 
    // Incluimos la configuracion 
    include_once("config.php"); 
    // Extraemos todos los post 
    $posts = mysql_query("SELECT * FROM foro"); 
    // Los guardamos 
    $datos_del_post = mysql_fetch_array($posts); 
?> 

<?php 
    if(isset($_SESSION['k_username'])){ 
        echo ' 
            <!DOCTYPE html> 
            <html lang="ES"> 
                <head> 
                    <title></title> 
                </head> 
                <body> 
                <a href="agregar/">Nuevo Tema</a> 
                Bienvenido '.$_SESSION['k_username'].' 
                <a href="logout.php">Salir</a> 
                <table width="1000" border="1"> 
                    <tr> 
                        <td colspan="2">Yu-Gi-Oh! Argentina</td> 
                        <td>Respuestas</td> 
                        <td width="200">Ultimos Mensajes</td> 
                    </tr> 
            '; 
                        mysql_data_seek($posts,0); 
                        while($datos_del_post = mysql_fetch_array($posts)){ 
            echo' 
                    <tr> 
                        <td width="74" rowspan="2">&nbsp;</td> 
                        <td width="492"><a href="foro.php?titulo='.urlencode($datos_del_post['titulo']).'">'. $datos_del_post['titulo'].'</a></td> 
                        <td rowspan="2">'.$datos_del_post['respuestas'].'</td> 
                        <td rowspan="2">&nbsp;</td> 
                    </tr> 
                    <tr> 
                        <td>por <a href="profile.php?usuario='.$datos_del_post['autor'].'">'.$datos_del_post['autor'].'</a></td> 
                    </tr> 
            '; 
                        } 
            ' 
                </table> 
            </body> 
        </html>    '; 
    }else{ 
        echo' 
            <!DOCTYPE html> 
            <html lang="ES"> 
                <head> 
                    <title></title> 
                </head> 
                <body> 
                <a href="agregar/">Nuevo Tema</a> 
                <form action="login/login.php" method="post"> 
                    <input type="text" name="login_user" id="login_user" placeholder="Usuario" /> 
                    <input type="password" name="login_pass" id="login_pass" placeholder="Contrase&ntilde;a" /> 
                    <input type="submit" name="login_submit" id="login_submit" value="Entrar" /> 
                    <a href="register/">Registrarse</a> 
                </form> 
                <table width="1000" border="1"> 
                    <tr> 
                        <td colspan="2">Yu-Gi-Oh! Argentina</td> 
                        <td>Respuestas</td> 
                        <td width="200">Ultimos Mensajes</td> 
                    </tr> 
            '; 
                        mysql_data_seek($posts,0); 
                        while($datos_del_post = mysql_fetch_array($posts)){ 
            echo ' 
                    <tr> 
                        <td width="74" rowspan="2">&nbsp;</td> 
                        <td width="492"><a href="foro.php?titulo='.urlencode($datos_del_post['titulo']).'">'. $datos_del_post['titulo'].'</a></td> 
                        <td rowspan="2">'.$datos_del_post['respuestas'].'</td> 
                        <td rowspan="2">&nbsp;</td> 
                    </tr> 
                    <tr> 
                        <td>por <a href="profile.php?usuario='.$datos_del_post['autor'].'">'.$datos_del_post['autor'].'</a></td> 
                    </tr> 
            '; 
                        } 
            ' 
                </table> 
            </body> 
        </html>    '; 
    }     
?> 

foro.php --> este seria donde se muestra el tema y tendria que estar sus respuestas abajo

Código HTML:
<?php 
    // Incluimos la configuracion 
    include_once("config.php"); 
    // Extraemos todos los post 
    $posts = mysql_query("SELECT * FROM foro WHERE titulo='".$_GET['titulo']."'"); 
    // 
    mysql_data_seek($posts,0); 
    // Los guardamos 
    while($datos_del_post = mysql_fetch_array($posts)){ 
?> 

<!DOCTYPE html> 
<html lang="ES"> 
    <head> 
        <title><?php echo $datos_del_post['titulo']?></title> 
    </head> 
    <body> 
        <?php echo $datos_del_post["mensaje"]; ?> 
    </body> 
</html>     

<?php 
    } 
?>