tags:

views:

58

answers:

2

Hello all, my WHERE do so my page dont work and i dont know how i do so then a user create a comment then a number in my thread will grow +1.

i wanna do this because then i user create a new comment the users who follow that thread can see "oh there is a new comment to the topic o follow"

here is my code

    if(isset($_POST['opret_kommentar']))
{
    $nyt_svar = 0;
    $mysql2 = connect();
    $stmt2 = $mysql2->prepare("INSERT INTO forum_traad (nyt_svar) VALUES (?) WHERE id = '$traadID'") or die($mysql->error);
    $stmt2->bind_param('i', $nyt_svar) or die($mysql->error);
    $stmt2->execute();

    $indhold = htmlspecialchars($_POST['indhold']);
    $godkendt = "ja";

    $mysql = connect();
    $stmt = $mysql->prepare("INSERT INTO forum_kommentare (fk_forum_traad, brugernavn, indhold, godkendt) VALUES (?,?,?,?)") or die($mysql->error);
    $stmt->bind_param('isss', $traadID, $_SESSION['username'], $indhold, $godkendt) or die($mysql->error);
    $stmt->execute();
    $stmt->close();

    $svar = mysqli_insert_id($mysql);   

    header("location: forum.traad.php?traadID=$traadID&kategoriID=$kategoriID&#$svar");

}
+1  A: 

So you mean, where ~ VALUES (VAR+1) ?

DavidYell
+2  A: 

If you have an existing thread record which you want to increment, you will want to use an UPDATE statement rather than INSERT.

For example:

UPDATE forum_traad SET nyt_svar = (nyt_svar + 1) WHERE id = '$traadID';

JYelton