Jump to content

Won't update


I-R-Fool

Recommended Posts

Ok, so i have a ask me script, with an acp, but now i need to update the comments, but what i ahve so far is not doing what i need it to do.form:

	  <form method='POST'>	  <input name='comment' type='text' value='".$row['comment']."'></input>	  <button type='submit' name='submit'>Submit</button>	  </form>

sql update:

if (isset($_POST['submit'])){mysql_query("UPDATE aSET comment=".$_POST['comment']."WHERE id=".$row['id']."");

So basically, it needs to update the comment on the block i pressed submit on.Idk if its the where that messes it up, but how am i going to make it so it updates only the comment where i pressed submit, and not the others?

Link to comment
Share on other sites

  • 1 month later...

u have to pass the 'id' in order to get it back in where clause. u can pass it, tipically, through by an hidden input included in the update formyour form should look like

	 <form method='POST'>	  <input name='comment' type='text' value='".$row['comment']."'></input>	  <input name='id' type='hidden' value='".$row['id']."'></input>	  <button type='submit' name='submit'>Submit</button>	  </form>

thus

if (isset($_POST['submit'])){mysql_query("UPDATE aSET comment='".$_POST['comment']."'WHERE id='".$_POST['id']."'");

also you forgot to quote the 'comment'.regards

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...