apw Posted October 20, 2008 Share Posted October 20, 2008 Hello I'm working on a script that handles the form add, subtracts and even multiplies the variables and queries the SQL. When player registers, the player receives the following: * 100 peasants * 0 labor * 0 manpower The script changes the players number of peasants to labor .. when player changes the labor amount, the player also receives 2-points per labor receives: Please check over the script, the peasants, labor and manpower isn't changing... ajobs.php (form action handle) <?php if ($userstats3[peasants]<=0) { print "Not enough peasants"; } else { print "You have $userstats3[peasants] peasants available!<br>"; print "<form action='ajob.php' method='post'>"; print "<input type='text' name='lesspeasant' size='5'><br>"; print "<input type='submit' name='submit' value='Change'></form>"; } ?> from ajob.php <?php include 'connect.php'; session_start(); ?> <link rel="stylesheet" href="style.css" type="text/css"> <?php if (isset($_SESSION['player'])) { $player=$_SESSION['player']; $userstats="SELECT * from km_users where playername='$player'"; $userstats2=mysql_query($userstats) or die("Could not get user stats"); $userstats3=mysql_fetch_array($userstats2); if(isset($_POST['submit'])) { $lesspeasant=$_POST['lesspeasant']; $lesspeasant=strip_tags($lesspeasant); $lesslaboe=$_POST['lesslabor']; $lesslabor=strip_tags($lesslabor); print "<center>"; print "<table class='maintable'>"; print "<tr class='headline'><td><center>Buy Science</center></td></tr>"; print "<tr class='mainrow'><td>"; if($peasant<0) { print "You cannot change, not enough peasants!. Back to <A href='index.php'>Main</a>"; } else if($userstats3[playerturns]<1) { die("You must have at least 1 turn to Change. Go back to <A href='index.php'>Main</a>"); } $lesspeasants=$userstats3[peasants]; $lesspeasant=$userstats3[peasants]-$lesspeasant; $lesslabor=$lesspeasant; $userstats3[labor]=$lesspeasant; $userstats3[labor]*2; $updatestats="update km_users set peasants=peasants-'$lesspeasant', playerturns=playerturns-1 where ID='$userstats3[iD]'"; mysql_query($updatestats) or die("Could not update stats"); print "You Changed $lesspeasant peasants to labor and have $manpower manpower and $userstats3[labor] laborers! Back to <A href='index.php'>Main Page</a>"; } print "</td></tr></table>"; } else { print "Sorry, not logged in please <A href='login.php'>Login</a><br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/129305-query-with-math-help/ Share on other sites More sharing options...
Barand Posted October 20, 2008 Share Posted October 20, 2008 Double post - locked Link to comment https://forums.phpfreaks.com/topic/129305-query-with-math-help/#findComment-670398 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.