Jump to content

ADDING results to field?


gesseg

Recommended Posts

Hi, Im trying (and failing) to add results from a form to existing results in the table.

So if the row "skill" was 10 then the form submitted had a skill value of 5 the table would update to 15. Im sure there is an easy way of doing this but Ive searched the web and canfind one.

 

Heres my code:

<?php
$con = mysql_connect("host","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("database", $con);
$result = mysql_query("SELECT skill FROM database WHERE name = '$_POST[name]'");


mysql_query("UPDATE database SET skill = '$_POST[skill] + $result'
WHERE name = '$_POST[name]'");

mysql_close($con);
?>

Link to comment
https://forums.phpfreaks.com/topic/204706-adding-results-to-field/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.