To all experts who is going to read this question, It is a basic problem that cost me more than hours to me,
I want to update previously entered row. As it can be seen in the code, I want to update Improvement column. Also I want to do that with the help of the last user id, which is a auto increment primary key entry. However with the code I wrote down here nothing changes in my Mysql database.
$sql = "
UPDATE users
SET Improvement='".$improvement."'
WHERE ORDER BY User_id DESC LIMIT 1
";
mysql_query($sql, $accounts);
And as you can see this is my table in mysql,
users CREATE TABLE `users` (
`Username` varchar(30) COLLATE latin1_general_ci NOT NULL,
`Age` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Education` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Department` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Favourite` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Preference` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Lpreference` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Level` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Question` varchar(20) COLLATE latin1_general_ci NOT NULL,
`Improvement` int(11) NOT NULL,
`User_id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`User_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
I believe I cannot update Improvement column because of the syntax. In my page no error occurs, and nothing happens even though $improvement not equal to 0. I echo the $improvement variable it is not equal to 0. But noting changes in my database.
I am desperate for an answer, If it works I will select it as best answer for other people who is facing the same problem.