Jump to content

Archived

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

tstats

Finally have it working - update MYSQL Query

Recommended Posts

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 line
mysql_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 -

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

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.