¿sería (isVisible = 1) trabajan en esta situación?

  • iWiGG_2010
  • Newbie
  • Newbie
  • Avatar de Usuario
  • Registrado: Nov 22, 2011
  • Mensajes: 10
  • Loc: Australia
  • Status: Offline

Nota Noviembre 25th, 2011, 8:48 pm

Hola chicos,

Sólo preguntando ¿cómo configuro un administrador para controlar un sistema de observación. Estoy pensando en algo como esto:

Una fila de "admin" en la tabla "post" y cuando los usuarios escribir un comentario, el administrador tiene la opción de hacerla visible o mostrarlo. Comentario de moderación (isVisible = 1), por lo que el administrador puede desactivar comentarios en la base de datos.

¿Sería la (isVisible = 1) trabajan para esto? ¿1 lo que significa es visto y permitido por admin y 0 no visible?

Si es así, ¿cómo sería si mira como? ¿Y lo que coloca en la base de datos?

Esta es mi tabla:

puesto de la tabla
int(11) identificador principal de AUTO_INCREMENT
album_id tinyint(4)
topic_id int(11)
post_creator int(11)
texto post_title
post_date datetime
admin int(11) defult: 1

Este es el código:

post_reply.php

PHP Código: [ Select ]
<?php
if ((!isset($_SESSION['user_id'])) || ($_GET['cid'] == "")) {
        header("Location: index.php");
        exit();
}
$cid = $_GET['cid'];
$tid = $_GET['tid'];
?>
 
<form action="post_reply_parse.php" method="post">
        <p>Reply Content</p>
        <p><br>
    </p>
    <p>&nbsp;    </p>
    <p>
      <textarea name="reply_content" rows="5" cols="75"></textarea>
      <br /><br />
      <input type="hidden" name="cid" value="<?php echo $cid; ?>" />
      <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
      <input type="submit" name="reply_submit" value="Reply" />
    </p>
</form>
 
  1. <?php
  2. if ((!isset($_SESSION['user_id'])) || ($_GET['cid'] == "")) {
  3.         header("Location: index.php");
  4.         exit();
  5. }
  6. $cid = $_GET['cid'];
  7. $tid = $_GET['tid'];
  8. ?>
  9.  
  10. <form action="post_reply_parse.php" method="post">
  11.         <p>Reply Content</p>
  12.         <p><br>
  13.     </p>
  14.     <p>&nbsp;    </p>
  15.     <p>
  16.       <textarea name="reply_content" rows="5" cols="75"></textarea>
  17.       <br /><br />
  18.       <input type="hidden" name="cid" value="<?php echo $cid; ?>" />
  19.       <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
  20.       <input type="submit" name="reply_submit" value="Reply" />
  21.     </p>
  22. </form>
  23.  


post_reply_parse.php

PHP Código: [ Select ]
<?php
 
if ($_SESSION['user_id']) {
        if (isset($_POST['reply_submit'])) {
               
                $creator = $_SESSION['user_id'];
                $cid = $_POST['cid'];
                $tid = $_POST['tid'];
                $reply_content = $_POST['reply_content'];
                $sql = "INSERT INTO posts (album_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$tid."', '".$creator."', '".$reply_content."', now()) ";
                $res = mysql_query($sql) or die(mysql_error());
               
                $sql2 = "UPDATE albums SET last_post_date=now(), last_user_posted='".$creator."' WHERE album_id='".$cid."' LIMIT 1 ";
                $res2 = mysql_query($sql2) or die(mysql_error());
               
                $sql3 = "UPDATE topics SET topic_reply_date=now(), topic_last_user='".$creator."' WHERE album_id='".$tid."' LIMIT 1 ";
                $res3 = mysql_query($sql3) or die(mysql_error());
 
 
                if (($res) && ($res2) && ($res3) .is(':visible') = 1){
                        echo "<br /><p>Your reply has successfully posted. <a href='view_topic.php?cid=".$cid."&tid=".$tid."'>Click here to return to the topic.</a></p>";
                } else {
                        echo "<p>There was a problem posting your reply! Please try again later.</p>";
                }
               
        } else {
                exit();
        }
} else {
                exit();
}
 
?>
 
  1. <?php
  2.  
  3. if ($_SESSION['user_id']) {
  4.         if (isset($_POST['reply_submit'])) {
  5.                
  6.                 $creator = $_SESSION['user_id'];
  7.                 $cid = $_POST['cid'];
  8.                 $tid = $_POST['tid'];
  9.                 $reply_content = $_POST['reply_content'];
  10.                 $sql = "INSERT INTO posts (album_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$tid."', '".$creator."', '".$reply_content."', now()) ";
  11.                 $res = mysql_query($sql) or die(mysql_error());
  12.                
  13.                 $sql2 = "UPDATE albums SET last_post_date=now(), last_user_posted='".$creator."' WHERE album_id='".$cid."' LIMIT 1 ";
  14.                 $res2 = mysql_query($sql2) or die(mysql_error());
  15.                
  16.                 $sql3 = "UPDATE topics SET topic_reply_date=now(), topic_last_user='".$creator."' WHERE album_id='".$tid."' LIMIT 1 ";
  17.                 $res3 = mysql_query($sql3) or die(mysql_error());
  18.  
  19.  
  20.                 if (($res) && ($res2) && ($res3) .is(':visible') = 1){
  21.                         echo "<br /><p>Your reply has successfully posted. <a href='view_topic.php?cid=".$cid."&tid=".$tid."'>Click here to return to the topic.</a></p>";
  22.                 } else {
  23.                         echo "<p>There was a problem posting your reply! Please try again later.</p>";
  24.                 }
  25.                
  26.         } else {
  27.                 exit();
  28.         }
  29. } else {
  30.                 exit();
  31. }
  32.  
  33. ?>
  34.  


Espero que esta marca sence.

Saludos
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Noviembre 25th, 2011, 8:48 pm

  • Bogey
  • Bogey
  • Genius
  • Avatar de Usuario
  • Registrado: Jul 14, 2005
  • Mensajes: 8212
  • Loc: USA
  • Status: Offline

Nota Noviembre 26th, 2011, 10:44 pm

No necesita poner isVisible en otra tabla solo mantenerlo en la tabla de puestos poner 0 (o 1 si desea tenerlo visible) en la primera y única permiten al usuario con privilegios de administrador para cambiar a 0 o 1.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • iWiGG_2010
  • Newbie
  • Newbie
  • Avatar de Usuario
  • Registrado: Nov 22, 2011
  • Mensajes: 10
  • Loc: Australia
  • Status: Offline

Nota Noviembre 26th, 2011, 11:55 pm

Gracias por su respuesta.

Tengo una fila de admin en la mesa de entradas.

tipo de admin: TINYINT (1)
predeterminado = 1

Simplemente no entiendo cómo escribir el código de función para isVisible = 1
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de Usuario
  • Registrado: Dic 20, 2002
  • Mensajes: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Nota Noviembre 27th, 2011, 12:16 am

Estoy un poco confundido sobre qué parte no entiendes. ¿Están queriendo saber cómo tomar los datos de la tabla y, a continuación, escribir un if instrucción sobre si el valor es 0 o un 1 para la variable de tipo admin? Podría explicar más detalladamente qué parte están entendiendo no por lo que podremos asegurarnos de responder a la pregunta correcta. ¡ Gracias!
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • iWiGG_2010
  • Newbie
  • Newbie
  • Avatar de Usuario
  • Registrado: Nov 22, 2011
  • Mensajes: 10
  • Loc: Australia
  • Status: Offline

Nota Noviembre 27th, 2011, 12:21 am

Hola,

Lo siento por la confusión.

Podría por favor obtener ayuda sobre cómo escribir if instrucción por favor.

Esto es todo nuevo para mí
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de Usuario
  • Registrado: Dic 20, 2002
  • Mensajes: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Nota Noviembre 27th, 2011, 12:28 am

Lo primero que haría es escribir una consulta SQL para obtener el puesto de datos para cualquier puesto alguien está mirando. Una de esas variables que usted hubiera cogido de la instrucción SQL sería para la variable admin_type. Esto es sólo un ejemplo, pero permite decir que almacena dicho valor en:

$datos ["admin_type"]

Entonces el si sería la declaración como

PHP Código: [ Select ]
if($data['admin_type']) { //true if value is 1
//show the post
}
else { //if not true then must be false
//show an error or something to indicate the post is not visible
}
  1. if($data['admin_type']) { //true if value is 1
  2. //show the post
  3. }
  4. else { //if not true then must be false
  5. //show an error or something to indicate the post is not visible
  6. }
Ozzu Hosting - Want your website on a fast server like Ozzu?

Publicar Información

  • Total de mensajes en este tema: 6 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 218 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC