E
E
exedis2015-09-21 11:16:24
PHP
exedis, 2015-09-21 11:16:24

How to moderate comments?

Hello, there is a form that displays a table (name, sms) and a field with a checkbox from the database, that is, if the checkbox is checked, then publish a comment. But I can’t seem to get it to “synchronize” with the database after putting down the checkboxes! That is, if for example I mark some field, then simply {1,2} is displayed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2015-09-21
@n1ger

Maybe you first need to add a column (publication) to the comments table.
And then just check the box, and the publication becomes equal to 1, remove it becomes 0 (or true / false), something like that.

if($action == 'public' || $action == 'unpublic') {
    if ($action == 'public') $pub = 1;
    else if ($action == 'unpublic') $pub = 0;

    exec_sql("UPDATE $table_comments SET comments_show = '$pub' WHERE comments_id = $com_id");
}

And in the output of comments on the page. display the comments that should be published,
SELECT COUNT(*) total_items FROM $table_comments WHERE comments_show = 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question