Thanks, but I don't understand how I can get the comment ID?
Printable View
Thanks, but I don't understand how I can get the comment ID?
I can't edit, please merge.
select comment from comments where id = '$id'
If my database table was petitio, would I replace comment or comments with petition? I'm pretty sure i'd replace comments but I want to double check.
And, I would really appreciate if someone could tell me how to get the ID, as this is the only thing holding me back now.
Add a new field to your database, make it a primary key and auto-increment.
Then do
And im presuming your using a while loop to display comments, so it should be in that..PHP Code:<?php
$get_id = mysql_fetch_array(mysql_query("select id from comments"));
$id = $get_id[id];
?>
Of course it is possible. Not very clean code, not on my PHPDesigner computer.
Then edit.php:PHP Code:<?php
include "config.php";
$get_query = mysql_query("SELECT * FROM table ORDER BY id DESC");
while($row = mysql_fetch_array($get_query)) {
$field = $row["field"];
$id = $row["id"];
echo "$field - <a href=\"edit.php?id=$id\">Edit</a>";
}
?>
PHP Code:<?php
include "config.php";
$id = $_GET["id"]; // Be sure to use a good clean function to do it with. If you have one uncomment the next line
# $id = Clean($_GET["id"]);
if($_GET["action"] == "edit") {
$field = $_POST["field"];
# $field = clean($_POST["field"]);
mysql_query("UPDATE table SET field='$field' WHERE id='$id'") or die(mysql_error());
echo "Record updated!";
exit;
}
$get = mysql_query("SELECT * FROM table WHERE id='$id' LIMIT 0,1");
$row = mysql_fetch_array($get);
?>
<form action="?action=edit&id=<?php echo $_GET["id"]; ?>" method="post">
<table>
<tr><td>Field:</td> <td><input type="text" name="field" value="<?php echo $row["field"]; ?>"></tr>
<tr><td> </td> <td><input type"submit" name="submit" value="Edit"></td>
</table>
</form>
Whats special about your PHPDesigner computer?
Good luck with the editing :)
Read my post.. :p
I have, read my new thread pls. :)