Query

Hi all

I have create a database where people can post comments, ideas enter jokes etc, but before displaying them on the screen i have to make sure that they are not offended to any one? I need some bulk place from where i can send to the screen.
Any ideas??

So add a field to your database table along the lines of “moderated”. Default value 0.
If moderated = 0, dont show it on the main display page.
Create a new screen for the administrator, which shows all unmoderated (moderated = 0) jokes.
That page has buttons to approve the jokes (set moderated = 1).

can you show a simple example of what code will be look like?
I am new to the PHP and MySQL

The filtering of the jokes would be handled by your query, so without that, i cant show you anything.

Pushing a button on the moderator screen should execute an UPDATE query setting moderated = 1 WHERE id = <the jokes ID>

this is my index.php script:
<?php
include_once $_SERVER[‘DOCUMENT_ROOT’] .
‘/includes/magicquotes.inc.php’;
if (isset($_GET[‘addjoke’]))
{
include ‘form.html.php’;
exit();
}
if (isset($_POST[‘joketext’]))
{
include $_SERVER[‘DOCUMENT_ROOT’] . ‘/includes/db.inc.php’;
try
{
$sql = ‘INSERT INTO joke SET
joketext = :joketext,
jokedate = CURDATE()’;
$s = $pdo->prepare($sql);
$s->bindValue(‘:joketext’, $_POST[‘joketext’]);
$s->execute();
}
catch (PDOException $e)
{
$error = ‘Error adding submitted joke: ’ . $e->getMessage();
include ‘error.html.php’;
exit();
}
header(‘Location: .’);
exit();
}
if (isset($_GET[‘deletejoke’]))
{
include $_SERVER[‘DOCUMENT_ROOT’] . ‘/includes/db.inc.php’;
try
{
$sql = ‘DELETE FROM joke WHERE id = :id’;
$s = $pdo->prepare($sql);
$s->bindValue(’:id’, $_POST[‘id’]);
$s->execute();
}
catch (PDOException $e)
{
$error = 'Error deleting joke: ’ . $e->getMessage();
include ‘error.html.php’;
exit();
}
header(‘Location: .’);
exit();
}
include $_SERVER[‘DOCUMENT_ROOT’] . ‘/includes/db.inc.php’;
try
{
$sql = ‘SELECT joke.id, joketext, name, email
FROM joke INNER JOIN author
ON authorid = author.id’;
$result = $pdo->query($sql);
}
catch (PDOException $e)
{
$error = 'Error fetching jokes: ’ . $e->getMessage();
include ‘error.html.php’;
exit();
}
foreach ($result as $row)
{
$jokes = array(
‘id’ => $row[‘id’],
‘text’ => $row[‘joketext’],
‘name’ => $row[‘name’],
‘email’ => $row[‘email’]
);
}
include ‘jokes.html.php’;
?>