Hello,

i am trying to update a table row from a form the code is:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="votim" id="votim">
	    <p>
	      <input type="hidden" name="email" id="email"  value="<?php echo $usernamepervotime ?>"/>
          <input type="hidden" name="vota" id="vota"  value="<?php htmlentities($row_VotaMiss['vota']+1); ?>"/>
          <input type="hidden" name="ID" id="ID"  value="<?php echo $row_VotaMiss['ID']; ?>"/>
        </p>
	    <p>&nbsp;</p>

	    <p><a href="#" onclick="document['votim'].submit()">Voto</a></p>
        
<?php 
if(isset($_POST['email'])){
$email = $_REQUEST['email'];
$vota = $_POST['vota'];
$id = $_POST['ID'];
$update = mysql_query("UPDATE table SET vota=$vota WHERE ID=$id");
	 }
?>
        </form>

but it wont work... can anyone help me??? the row table has 11 columns and the column i want to update is the last one named "vota"

thank you in advance
NiKu

Member Avatar for nileshgr

Paste the output of var_dump($_POST) inside the if condition.

Member Avatar for rajarajan2017

Echo all the variables you have and ensure you received values before using update

$update = mysql_query("UPDATE table SET vota='$vota' WHERE ID='$id'");

Also try with the single quotes like above.

if (mysql_num_rows($update) > 0) { 
echo "rows affected";
} else echo "rows doesnot affected";

Also add the above statements and check whether it affected the rows or not.

Member Avatar for nileshgr

@raja, Even I had thought he needed quotes, but no; quotes are not required for numeric fields. That's why I asked him to dump $_POST.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.