Whenever I execute an update-query, my whole table is updated. What do I have to do when I just want ONE value to be updated?
Here is my database structure:
ID || photo || sequence
1 || test.png || 1
2 || bla.png || 2
Whenever I execute this script,
if (isset($_POST['submitted'])) {
$project = new Project();
$project->sequence = $_POST['sequence'][$key];
$projectid = $_POST['photoid'];
if($project->updateProject($_DB, $projectid)) {
$feedback = "OK";
} else {
$feedback = "NOT OK";
}
}
Results in this:
ID || photo || sequence
1 || || 4
2 || || 2
So, what do I have to do to just update the sequence-value in the database without touching the rest of the data in the database…
FUNCTION:
public function updateProject($db, $id) {
$sql = "UPDATE tblProject SET
sequence = '".$db->escape($this->sequence)."'
WHERE id = '".$id."'";
return $db->insert($sql);
}
INSERT FUNCTION:
public function insert($sql) {
mysql_query($sql, $this->_connection);
return mysql_affected_rows($this->_connection);
}
There must be a problem with your
$project->updateProject()function.Try with simple query: