Jump to content

[SOLVED] update database in specific id


Recommended Posts



I've made a script which gets posts from a database which needs to be accepted before it's put on the site. but when I try to update a post on the admin page I've made some kind of mistake since it always update the last id in the database thats need to be accepted and not the actual one you click on. here's the full code:


<?php include("header.php"); ?>


<?php if(isset($_POST['acc'])) {

$accid = $_POST['accid'];


$update=mysql_query("update fansaker set acc='1' where 'id'='$accid'");








$adminsql=mysql_query("select * from fansaker where acc = 0 order by id");


print "<table border='0' width='400' cellspacing='0' cellpadding='0' align=center>";


print "<form name=acc' method='post' action='acc.php'>";




print "<tr><td><b>id:</b> <input type='hidden' name='accid' value='$n1[id]'>$n1[id]</td>";


print "<tr bgcolor=#f1f1f1><td colspan=2>$n1[comment] <b>FTML</b></td></tr>";


print "<tr><td><input type='submit' name='acc' value='accept'>

  <input type='submit' name='del' value='delete'></td></tr>";





print "</table>";





any help would be appreciated!

Link to comment
Share on other sites

hi, yep when I echo the id in the formular (the red) I have the right id


print "<tr><td><b>id:</b> <input type='hidden' name='accid' value='$n1[id]'>$n1[id]</td>";


but when I send it to update the script it always the last id, I've tried to echo here before updating the databas and it always gives me the last id...

Link to comment
Share on other sites

1)  You don't need single quotes around 'id' in your query.


Change it to this and see if it makes a difference or outputs any errors.


 $update=mysql_query("update fansaker set acc='1' where id='$accid'") or die(mysql_error());


2)  You need to end your form.


3)  Like ober said, the value is not going to magically change from the form to the action script if that's your entire code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.