PHP - Help With Sales Tax Subtraction
Similar TutorialsHello, I am running this script: Code: [Select] while($row = mysql_fetch_array($query)) { $compare_points_1 = $row['sideone_points']; $compare_villages_1 = $row['sideone_villages']; $compare_members_1 = $row['sideone_members']; $compare_points_2 = $row['sidetwo_points']; $compare_villages_2 = $row['sidetwo_villages']; $compare_members_2 = $row['sidetwo_members']; } $point_1 = $_POST['points_1']; $village_1 = $_POST['villages_1']; $member_1 = $_POST['members_1']; $point_2 = $_POST['points_2']; $village_2 = $_POST['villages_2']; $member_2 = $_POST['members_2']; $points_1_calc = $compare_points_1 - $point_1; $villages_1 = $compare_villages_1 - $village_1; $members_1 = $compare_members_1 - $member_1; $points_2 = $compare_points_2 - $point_2; $villages_2 = $compare_villages_2 - $village_2; $members_2 = $compare_members_2 - $member_2; When I try to output $points_1_calc it gives me: -100 It will Add & Times & Divide but not Subtract. Everything fills with Numbers only and I've tried this seperately and it works on a different script where I manually put in the numbers. All variables fill with numbers as I have a part above that doesnt go through if there is nothing to compare against. Any help would be greatly appreciated. This should be simple. However, when I run the script and input a say 18 char long string, it still returns -10. The variable char_total is accurately capturing the string length. Code: [Select] <?php $inputid = $_POST['steamid']; $steam_prefix = substr($inputid, 0, 10); $prefix_length = 10; $steam_suffixchars = ($char_total - $prefix_length); $char_total = strlen($inputid); if($char_total > 25 || $char_total < 11) $char_valid = false; else $char_valid = true; if($steam_prefix === "STEAM_0:1:" || $steam_prefix === "STEAM_0:0:") $prefix_check = true; elseif($steam_prefix != "STEAM_0:1:" || $steam_prefix != "STEAM_0:0:") $prefix_check = false; echo "$steam_suffixchars" ?> hi, i am working on an assignment in which i am getting current date and then getting date of two previous months i.e 2010-09 2010-08 2010-07 the problem is that the code is working perfectly on localhost but when i upload the file it only shows the current date and do not subtract and display dates. can some body guide me that what is the problem and how to solve it. here is the code $date1= date("Y-m"); $date2 = strtotime ( '-1 month' , strtotime ( $date1 ) ) ; $date2 = date ( 'Y-m' , $date2 ); $date3 = strtotime('-1 month', strtotime( $date2 ) ); $date3 = date( 'Y-m' , $date3); ?> <select name=""> <option><?php echo $date1; ?></option> <option><?php echo $date2; ?></option> <option><?php echo $date3; ?></option> </select> Hi all, I'm trying to make a webpage that allows the user to enter new sales figures for a certain product in a chosen month of a chosen year. I thought my code was correct but it doesn't really do anything. It just displays the table but it's not updated. Can anybody spot an error? Code: [Select] $describeQuery = "SELECT p.ID, p.NAME, dt.[Year], dt.[Month], dt.SalesVolume from Products p join (select ProductCode, sum(SalesVolume) as SalesVolume, [Month], [Year] from MonthlySales where [Year] = '$desiredYear' AND [Month] = '$desiredMonth' group by ProductCode, [Year], [Month])dt on dt.ProductCode = p.ID"; $editQuery = "UPDATE MonthlySales SET SalesVolume = '$newSales' WHERE Month ='$desiredMonth' AND Name = '$desiredProduct' AND Year = '$desiredYear'"; $results = sqlsrv_query($conn, $describeQuery); $resultsx = sqlsrv_query($conn, $editQuery); echo '<table border="1" BORDERCOLOR=Black>'; echo '<tr><th bgcolor = "LightBlue">Name</th><th bgcolor = "LightBlue" >ID</th> <th bgcolor = "LightBlue" >Sales</th><th bgcolor = "LightBlue" >Month</th> <th bgcolor = "LightBlue" >Year</th> </tr>'; while($row = sqlsrv_fetch_array($results, SQLSRV_FETCH_ASSOC)) { echo '<tr>'; echo '<td >' .$row['NAME'].'</td>'; echo '<td>' .$row['ID'].'</td>'; echo '<td>' .$row['SalesVolume'].'</td>'; echo '<td>' .$row['Month'].'</td>'; echo '<td>' .$row['Year'].'</td>'; echo '</tr>'; } echo '</table>'; while($row = sqlsrv_fetch_array($resultsx, SQLSRV_FETCH_ASSOC)) { } sqlsrv_close($conn); |