tstats Posted March 5, 2006 Share Posted March 5, 2006 Thanks for all of your help on this subject -I have two pieces of code - the first set of code is here:[code]<html><head><title></title></head><body><?$ud_id=$_POST['ud_id'];$ud_score1=$_POST['ud_score1'];$ud_score2=$_POST['ud_score2'];$ud_diff=$_POST['ud_diff'];//connect to db with password above this linemysql_select_db($db , $link)or die("Couldn't open $db: ".mysql_error());mysql_query(" UPDATE acsb061 SET score1='$ud_score1',score2='$ud_score2', diff='$ud_diff' WHERE id='$ud_id'");mysql_close($link);require 'updatenext.php';?></body></html> [/code]The second set of code is here - which updates the database -[code]<html><head><title></title></head><body><?$ud_id=$_POST['ud_id'];$ud_score1=$_POST['ud_score1'];$ud_score2=$_POST['ud_score2'];$ud_diff=$_POST['ud_diff'];$db = "tourname_Tour"; $link = mysql_connect("localhost","tourname","tmrcdrdlr");if (! $link)die("Couldn't connect to MySQL");mysql_select_db($db , $link)or die("Couldn't open $db: ".mysql_error());mysql_query(" UPDATE acsb061 SET team1='$ud_team1' ,team2='$ud_team2',score1='$ud_score1',score2='$ud_score2', diff='$ud_diff' WHERE id='$ud_id'");mysql_close($link);require 'updatefirst.php';?></body></html> [/code]Ok - so here is my question. Right now, I am having to enter the $diff in the html form - how would I write it so that the $diff in code set 1 above would be calculated?I would just enter the two scores and the $diff field (which is score1 - score2) would automatically be calculated and then passed through to the updatenext.php file -Thanks for the help - Quote Link to comment Share on other sites More sharing options...
Hooker Posted March 5, 2006 Share Posted March 5, 2006 This should work fine in place of $ud_diff=$_POST['ud_diff'];[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$ud_diff= $ud_score1 - $ud_score2;[/quote] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.