Version 8




    <LINK REL="stylesheet" href="css/estilo.css" TYPE="text/css">



    <head><title>Ejemplo Foro</title></head>




    <h3>Ejemplo Foro</h3><hr /><br />




    include_once ('inc/db_connect.php');


    if( isset($_REQUEST) ) {


       $article_id = $_REQUEST;


    } else {


       $article_id = 1;




    if( isset($_REQUEST)) {


    $id_libro = $_REQUEST;


    } else {


      $id_libro = 0;




    if (isset($_POST) ) {// Perform the insert of the new article    


       $title = $_POST;


       $content = $_POST;


       $article_id = $_POST;


       $id_libro = $_POST;


       if( isset($_SESSION) ){           


           $user_id = $_SESSION;   


       } else {           


          $user_id = 0;   




    $find_sql = "SELECT * FROM foros WHERE title = '$title' AND content = '$content'"; //busca el comentario


    $find_result = mysql_query($find_sql);


    $find_myrow = mysql_fetch_array($find_result);



    if (!$find_myrow) {//guarda comentario en la db


    $update_sql = "INSERT INTO foros (id_foro, author, id_libro, content, inputDate, fecha_comentario, title, originator) VALUES (0, '$user_id', '$id_libro', '$content', NOW(), NOW(), '$title', '$article_id')";


    $update_result = mysql_query($update_sql);   






    $a_result = "SELECT * FROM foros WHERE id_foro = '$article_id'"; //busca un determinado articulo

    $a_myrow = mysql_query($a_result);


    include_once ('forum_answer_content.php');    








    $a_result = "SELECT foros.*, usuarios.user FROM foros, usuarios WHERE usuarios.id_usuario = AND foros.id_foro = '$article_id'"; //busca un comentario segun un autor


    $a_myrow = mysql_query($a_result);$a_myrow = mysql_fetch_array($a_myrow);

    $resultCount = "SELECT count(1) AS count FROM foros WHERE originator = '$article_id'"; //devuelve la cantidad de comentarios realizados por un determinado autor

    $rowCount = mysql_query($resultCount);$rowCount = mysql_fetch_array($rowCount);

    $total = $rowCount;

    $id = $_SESSION;

    $result_user = "SELECT * FROM usuarios WHERE id_usuario='$id'";

    $row_user = mysql_query($result_user);

    $row_user = mysql_fetch_array($row_user);

    $user = $row_user;

    $page = 'forum_answer_add.php';



    <table class="style7" align="center" width="490" border="0" cellpadding="3" cellspacing="1">    


    <tr>     <td colspan="2" align="left" bgcolor="#EBEBEB" class="style7">




    $sql = "SELECT foros.*, user FROM usuarios, foros WHERE usuarios.id_usuario =  and originator = '$article_id' AND id_libro=0 AND usuarios.id_usuario = ORDER BY inputDate"; 

    $result = mysql_query($sql);


    if ($total == 0) { ?>


    <b> No hay respuestas </b>




    } else { ?>


    <b> Comentarios: </b>             <?php


    } ?>    


    </td>  </tr></table><br>




    while($myrow = mysql_fetch_array($result)){ ?>


    <table  width="490" align="center" border="0" cellpadding="4" cellspacing="1">




    <td align="left" bgcolor="#235CAB" width="110" class="style11">Autor: </strong><?php echo $myrow ?></td>


    <td align="center" bgcolor="#235CAB" class="style11">Título: </strong> <?php echo     $myrow ?></td>


    <td align="right" bgcolor="#235CAB" width="130" class="style11"><?php    echo $myrow ?></td>    </tr>   


    <tr>    <td align="left" bgcolor="#235CAB" width="130" class="style11"  colspan="3"><?php    echo $myrow ?>


    </td>    </tr></table><br><?php } ?>


    <table class="style7" align="right" width="490" bgcolor="#F7F7F7" border="0" cellpadding="3" cellspacing="1">


    <tr>    <td colspan="2" align="right">


    <a href="<?php echo $page?>?a=<?php echo $article_id ?> " target="_parent">Nuevo Comentario</a>   


    </td>  </tr></table>






    include_once ('inc/db_connect.php');


    if( isset($_GET) ){


    $article_id = $_GET;


    } else {   






    $sql = "SELECT * FROM foros WHERE id_foro = '$article_id'"; //busca un determinado articulo

    $t_result = mysql_query($sql);

    $t_myrow = mysql_fetch_array($t_result);


    $page = 'forum_list.php';




    <form method="post" action="<?php echo $page?>" onsubmit="return formcommentvalidation(this)">   


    <input type="hidden" name="a" value="<?php echo $article_id; ?>">


    <table width="95%" border="0" cellspacing="4" cellpadding="4" align="center">        




    <td class="style7" height="30" colspan="2" align="center" valign="top">


    <strong>Comentario</strong>        </td>    </tr>


    <tr>       <td  height="20" class="style7" align="left" >Título: </td>


    <td  height="20" class="style7" align="left" ><input name="title" type="text" value="" size="30"></td>    </tr>   


    <tr>         <td height="20" align="left" class="style7">Comentario: </td>


    <td height="20" align="left" class="style7"><textarea name="content" cols="35" rows="4"></textarea></td>    </tr>


    <tr>         <td colspan="2" height="20"> </td>    </tr>


    <tr>         <td colspan="2" height="20" align="center" class="style7"><input class="style37" type="Submit" name="submit" value="Siguiente"></td>   




    <tr>         <td height="30" colspan="2" align="center" valign="top" class="style37">        </td>    </tr></table>