Click here to Skip to main content
14,456,727 members
Rate this:
Please Sign up or sign in to vote.
See more:
<?php
$con=mysqli_connect('localhost','root','','onlinevotingweb');
$sql = "SELECT id, question, opt1,opt2,opt3,first,second,third FROM normalpoll";
		$bb=mysqli_query($con,$sql);

$ee=mysqli_num_rows($bb);

if ($ee>0) {
    // output data of each row
	$a=0;
while($row = $bb->fetch_assoc()){
	?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>Table with database</title>
    <style>
    table {
    border-collapse: collapse;
    width: 100%;
    color: #588c7e;
    font-family: monospace;
    font-size: 25px;
    text-align: left;
    }
    th {
    background-color: #588c7e;
    color: white;
    }
    tr:nth-child(even) {background-color: #f2f2f2}
    </style>
    </head>
    <body>
  
    



		<?php
	
    echo "<table>";
   echo" <tr>";
   echo "<th>question</th>";
	
	?>
	
	</tr>
	<?php
		echo  "<tr><td>".$row['question'] ."<td></tr>";
		?>

		<tr>
		    <th>option</th>
	    <th>option2</th>

    <th>option3</th>
</tr>
<tr>

   <form action="normal3.php" method="post">
<td><input type="radio" name="<?php  $row['id']; ?>" value="<?php  $row['first']; ?>"><?php echo $row['opt1']; ?></td>

<td><input type="radio" name="<?php  $row['id']; ?>" value="<?php  $row['second']; ?>"><?php echo $row['opt2']; ?></td>

<td><input type="radio" name="<?php  $row['id']; ?>" value="<?php  $row['third']; ?>"><?php echo $row['opt3']; ?></td>
<td><input type="button" name="submit" value="$row['id']" ></td>

</tr>
<br>
<br>



		</tr>
		    <th>first</th>
    <th>second</th>
    <th>third</th>
    </tr>
	<?php
	if(isset($_POST['submit'])){
	$answer = $row['first']; 
 $idd = $row['id']; 
	$id=$row['id'];
		$first=$row['first'];
echo"abc";
$a="UPDATE normalpoll SET first=$first+1 WHERE  id=\"$id\" ";
		$j=mysqli_query($con,$a);

	}
	else{
		
		echo "problem";
	}

		echo "<td>".$row['first']."</td>";
		
		echo "<td>".$row['second']."</td>";
		echo "<td>".$row['third']."</td></tr>";


 }
 
$a++;

}


else{
	 
	 echo "error";
 }
?>
</form>

        </table>
    </body>
    </html>


What I have tried:

radio button not work properly in php when i submit value not increse or not work

I create a questioner .everything is OK but when I click on submit. The value not update and if I remove this if(isset($_POST['submit']) then value update or increase on database but when am not remove this if(isset($_POST['submit'])   the value not  update
Posted
Updated 17-Dec-19 20:27pm
v6
Comments
OriginalGriff 16-Dec-19 5:34am
   
"not work properly" or "it doesn't work" are probably the most useless problem reports we get - and we get them a lot. They tell us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
Use the "Improve question" widget to edit your question and provide better information.
Member 14690895 16-Dec-19 6:10am
   
sir i make a online voting web and i create a questioner .everything is OK but when i click on submit. the value not update and if i remove this if(isset($_POST['submit']) then value update or increase on database but when i write this if(isset($_POST['submit']) the value not updated or not execute
ZurdoDev 16-Dec-19 8:03am
   
Sounds like there is an issue with your if statement then.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100