Dear friends,
I am developin g online survey form. Please, suggest me i have a question.and three options for answer.for example-:
What is your favirite Country?
A-Pakistan
B-India
C-USA
now i put redio buttons against them.Users will come and vote for countries. and he can view result after vote that which country got more voteI just want to know how add +1 to to that country database record?
Answer form code is below-:
<h1 style="background: #97E2E1; width: 30%">Answer Section</h1>
<?PHP
$sql="SELECT * FROM qtab ORDER BY Qid DESC Limit 1";
$result=$conn->query($sql);
if(!$result){
die($conn->error);
}
While($row=$result->fetch_assoc()){
echo "<BR>"."Question: ".$row["Question"]." ?"."<BR>"."<BR>";
?>
<form action="result.php" method="POST">
<P>
<?PHP echo $row['AnsA']; ?>:<input type="radio" name="q" value="a" /> <BR></br>
<?PHP echo $row['AnsB']; ?>:<input type="radio" name="q" value="b" /><BR></br>
<?PHP echo $row['AnsC']; ?>:<input type="radio" name="q" value="c" /> <BR></br>
<input type="submit" name="submit" value="Submit" />
</p>
</form>
</body>
<?php
}
$conn->close();
?>
</html>
and result.php code is below..
<?PHP include "conn.php"; ?>
<!DOCTYPE HTML>
<html>
<head>
<title>Answer Section</title>
</head>
<body>
<?php
include "conn.php";
if (isset($_POST['submiit'])&& isset($_POST['q'])){
$answer=$_POST['q'];
$ques="hello";
$sql="UPDATE atab SET Question=$ques,$answer=$answer+1";
$result=$conn->query($sql);
if ($result){
echo("user ahs voted");
}
else {
echo("Error") ;
}
}
?>
awaiting ur promt reply...