Clinton Posted June 8, 2008 Share Posted June 8, 2008 I cannot figure this damn thing out. I spent probably the last 3 hours working on it changing variables, the calculations, etc. and I just can't get it. THe rest of the table works it is just not calculating correctly but it makes no sense to me. When I perform the calculations I don't have a problem with it. I don't know if it could be something with the elseif? Sometimes the signin could have a number in it, sometimes the signout could have a number in it, sometimes they both could have no numbers in it, but they will never have numbers in both sections at the same time. Any help would be appreciated: <?php session_start(); $tablename = $_POST['tablename']; $datecode = $_POST['datecode']; $producttype = $_POST['producttype']; $transactiondate = $_POST['transactiondate']; $joblocation = $_POST['joblocation']; $jobnumber = $_POST['jobnumber']; $signout = $_POST['signout']; $signin = $_POST['signin']; $outinby = $_POST['outinby']; $weight = $_POST['weight']; $page = $_POST['page']; $choice = $_POST['choice']; $type = $_POST['type']; $grandtotal = ($signin + $signout); $powder = mysql_query("SELECT new FROM master WHERE name = '$type'") or die(mysql_error()); if ( $signin == $signout) echo "<p> </p>"; elseif ( $signin == "") { while($sp = mysql_fetch_array($powder)){ $new = $sp['new']; $totalgrams = ($grandtotal * $new); $totalgrams = ($totalgrams / 453.59237); $weight = ($weight - $totalgrams); } } elseif ( $signout == "") { while($sp = mysql_fetch_array($powder)){ $new = $sp['new']; $totalgrams = ($grandtotal * $new); $totalgrams = ($totalgrams / 453.59237); $weight = ($weight + $totalgrams); } } else echo "<p> </p>"; $sql2 = "UPDATE weights SET currentweight = '$weight' WHERE tablename = '$tablename'"; echo $sql2; $result2 = mysql_query($sql2) or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/109205-solved-going-to-shoot-myself/ Share on other sites More sharing options...
DarkWater Posted June 8, 2008 Share Posted June 8, 2008 Can you be more specific? What's this supposed to do? Division? =P Link to comment https://forums.phpfreaks.com/topic/109205-solved-going-to-shoot-myself/#findComment-560204 Share on other sites More sharing options...
Clinton Posted June 8, 2008 Author Share Posted June 8, 2008 OK, it's pulling the 'weight' of the item from the previous post. Now, it wasn't updating correctly and I realized that was because I was accounting for the addition or subtraction or the item that this particular page was designed for. So basically I need to take the 'weight' as POSTed, account for the change and then update it. Let's say a car weights 1.3 tons. I've currently got 3 cars in the db so it should say 3.9. I want to take 1 car way so I do that. The variables passed are 'weight' 3.9 and signout '1'. Now, they aren't going to sign things in and out at the same time but I had to figure out a way to incorporate that, that's where the variable grandtotal comes in. If they are signing a car out then signout will be 1 and signout will be 0 and the total will still be 1. Then I need to take that total and times it by the weight of one car. In this case 1.3 * 1 = 1.3. But crazy's don't believe in pounds so I have to convert it to grams. So, 1.3 / 456.... blah blah. Then I have to take the weight as was reported from the POST and either add to it if I"m adding more cars to the inventory or subtract from it if I'm taking cars away. Then I want to enter that total updated weight into the system... and... it's not working. The damned thing hates me. I don't even understand it anymore. It's like I change one variable and it's way off and I change another and it's the opposite of what it's suppose to be. :-| Doesn' t make sense anymore. Link to comment https://forums.phpfreaks.com/topic/109205-solved-going-to-shoot-myself/#findComment-560209 Share on other sites More sharing options...
Clinton Posted June 8, 2008 Author Share Posted June 8, 2008 Nobody? Link to comment https://forums.phpfreaks.com/topic/109205-solved-going-to-shoot-myself/#findComment-560591 Share on other sites More sharing options...
Barand Posted June 8, 2008 Share Posted June 8, 2008 I would've thought that grandtotal should be the net value of signin - signout Link to comment https://forums.phpfreaks.com/topic/109205-solved-going-to-shoot-myself/#findComment-560612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.