I wanna make Vote script for my site it right now it looks like this //Input form
<form action='votes.php' method='post'>
<input type='hidden' name='buttonUp' value='1'/>
<input type='submit' name='submitVote' value='Vote Up'/>
</form>
And php file which process this
isset($_POST['submitVote'])) {
$sql="INSERT INTO answers
SET up = '$_POST[buttonUp]',
questionId = (SELECT id FROM quesitons WHERE id = '$_POST[id]');
";
Sql table has fields, id, answer, questionId, user, date, ip, up, down
So, if somebody like answer with specific ID, click on Vote Up, and in filed UP
should be updated value + 1. Few hours i am about this, and don't know how to make it. Also i suppose that there should be UPDATE answers SET...
but i try that also, and nothing...
Thank you
Table Questions
CREATE TABLE IF NOT EXISTS `pitanja` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pitanje` text NOT NULL,
`korisnik` varchar(255) NOT NULL,
`datum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
Here is Table Answers
CREATE TABLE IF NOT EXISTS `answers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`answer` text COLLATE utf8_unicode_ci NOT NULL,
`questionId` int(11) NOT NULL,
`user` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`ip` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`up` int(11) NOT NULL,
`down` int(11) NOT NULL,
PRIMARY KEY (`id`)
)