Dusaro Posted August 31, 2011 Share Posted August 31, 2011 Ok, i have setup a page to add points to a member using 2 tables as i have said in one of my older posts, now i am wanting to subtract an entered amount of points... removepoints.php <body> <form method="post" name="memberadd" action="points_remove_complete.php"> <label>Name:</label> <select name="memberid"> <?php $con = mysql_connect("localhost","slay2day_User","slay2day"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("slay2day_database",$con); $sqlquery="SELECT * FROM `members` Order By name"; $result=mysql_query($sqlquery,$con); while($row=mysql_fetch_array($result)) { echo "<option value='".$row['id']."'>".$row['name']."</option>"; } ?> </select> <br> <label>Points:</label> <input type="text" name="points" id="points" size="5"><br> <input type="submit" value="submit" /> </form> </body> points_remove_complete.php: <?php $id=$_POST['memberid']; $points=$_POST['points']; $con = mysql_connect("localhost","slay2day_User","slay2day"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("slay2day_database",$con); $sql="INSERT INTO slay2day_database.`points` VALUES (NULL,'$memberid','$points')"; if(mysql_query($sql,$con)) { echo 'Points removed.<br /><a href="../index.php">Return To Points List</a><br /><a href="removepoints.php">Remove More Points!</a>'; } else { die('Could not submit: ' . mysql_error()); } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/246088-subtract-from-row-in-table/ Share on other sites More sharing options...
voip03 Posted August 31, 2011 Share Posted August 31, 2011 $sql="INSERT INTO slay2day_database.`points` VALUES (NULL,'$memberid','$points')"; slay2day_database.`points ? http://www.w3schools.com/sql/sql_insert.asp Link to comment https://forums.phpfreaks.com/topic/246088-subtract-from-row-in-table/#findComment-1263817 Share on other sites More sharing options...
Dusaro Posted August 31, 2011 Author Share Posted August 31, 2011 so do i not need the slay2day_database.? Link to comment https://forums.phpfreaks.com/topic/246088-subtract-from-row-in-table/#findComment-1263820 Share on other sites More sharing options...
Dusaro Posted August 31, 2011 Author Share Posted August 31, 2011 nevermind i fixed it was very simple. I changed: $sql="INSERT INTO slay2day_database.`points` VALUES (NULL,'$memberid','$points')"; to: $sql="INSERT INTO slay2day_database.`points` VALUES (NULL,'$memberid','-$points')"; Link to comment https://forums.phpfreaks.com/topic/246088-subtract-from-row-in-table/#findComment-1263821 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.