2009/5/5 Gary <gwpaul@xxxxxxx>: > This just keeps getting weirder, the results change sometimes even when the > same info is entered.. > > This is the revised code (after some helpful hints from some readers) > > Anyone help, I am supposed to show this tomorrow to client. > Hi there, > Gary > > <?php > $_SESSION['sale_session']=$_POST['sale']; > $_SESSION['assess_session']=$_POST['assess']; > $_SESSION['county_session']=$_POST['county']; > > // checks if bot > if ($_POST['address'] != '' ){ > exit("Changed field"); > } > > > $sale_value=$_POST['sale']; > $assess_value=$_POST['assess']; > $county=$_POST['county']; > > $chester_ratio=.51; > $montco_ratio=.53; > $delco_ratio=.58; > /*$ratio=.51; > > > /*$correct_assess=($sale_value)*($ratio); this is now the assessment should > be */ > $chester_correct_assess=($sale_value)*($chester_ratio); > $montco_correct_assess=($sale_value)*($montco_ratio); > $delco_correct_assess=($sale_value)*($delco_ratio); > $x = (3)*(2) makes no sense. $x = 3 * 2 works, as $x = (3 * 2) does, too. But this is not an error at all. > > $chester_assess_difference=($assess_value)-($chester_correct_assess); > $montco_assess_difference=($assess_value)-($montco_correct_assess); > $delco_assess_difference=($assess_value)-($delco_correct_assess); > > /* $assess_difference=($assess_value)-($sale_value * $ratio); > $percent_difference=($assess_difference)/($assess_value);*/ > $chester_percent_difference=($chester_assess_difference)/($assess_value); > $delco_percent_difference=($delco_assess_difference)/($assess_value); > $montco_percent_difference=($montco_assess_difference)/($assess_value); > > $chester_percent_savings=($chester_percent_difference)*100; > $delco_percent_savings=($delco_percent_difference)*100; > $montco_percent_savings=($montco_percent_difference)*100; > > if($_COOKIE['county_cookie'] ==('Chester County') && > ($chester_assess_difference >=50000)) > > { Same thing here, you could write it like that instead: if ($_COOKIE['xy'] == 'my string without brackets' && $chester_assess_difference >= 50000) { // do something } > echo '<h2 style="margin:0;color:#ff0000;">Yes, Your property appears to > qualify!</h2><br /><br />'; > echo "You 1 believe your home would today sell for <b> > $".number_format($sale_value)." </b><br />"; > echo "Your current tax assessment is<b> > $".number_format($assess_value)."</b><br />"; > echo "You live in <b>$county </b><br />"; > echo "Your potential savings could be<b> " > .number_format($chester_percent_savings,0)."%</b><br /><br />"; > echo "According to preliminary calculations based on the information you > have entered, you may enjoy a savings of <b> > ".number_format($chester_percent_savings,0)."% </b>off a combined total of > county, school and township real estate taxes. Actual dollar amount savings > will differ depending on the township that the property is located. Please > contact my office for a more precise estimate of savings.<br />"; > > } > > elseif($_COOKIE['county_cookie']==('Delaware County') && > ($delco_assess_difference >=30000)) { > > > echo '<h2 style="margin:0;color:#ff0000;">Yes, Your property appears to > qualify!</h2><br /><br />'; > echo "You 2 believe your home would today sell for <b> > $".number_format($sale_value)." </b><br />"; > echo "Your current tax assessment is<b> > $".number_format($assess_value)."</b><br />"; > echo "You live in <b>$county </b><br />"; > echo "Your potential savings could be<b> " > .number_format($delco_percent_savings,0)."%</b><br /><br />"; > echo "According to preliminary calculations based on the information you > have entered, you may enjoy a savings of <b> > ".number_format($delco_percent_savings,0)."% </b>off a combined total of > county, school and township real estate taxes. Actual dollar amount savings > will differ depending on the township that the property is located. Please > contact my office for a more precise estimate of savings.<br />"; > } > elseif($_COOKIE['county_cookie']==('Montgomery County') && > ($montco_assess_difference >=50000)) > > { > echo '<h2 style="margin:0;color:#ff0000;">Yes, Your property appears to > qualify!</h2><br /><br />'; > echo "You 3 believe your home would today sell for <b> > $".number_format($sale_value)." </b><br />"; > echo "Your current tax assessment is<b> > $".number_format($assess_value)."</b><br />"; > echo "You live in <b>$county </b><br />"; > echo "Your potential savings could be<b> " > .number_format($montco_percent_savings,0)."%</b><br /><br />"; > echo "According to preliminary calculations based on the information you > have entered, you may enjoy a savings of <b> > ".number_format($montco_percent_savings,0)."% </b>off a combined total of > county, school and township real estate taxes. Actual dollar amount savings > will differ depending on the township that the property is located. Please > contact my office for a more precise estimate of savings.<br />"; > } > > elseif(($chester_assess_difference <=50000) && > ($chester_assess_difference>=1000)) { > echo '<h3 style="margin:0;">While it appears you may enjoy some savings, the > dollar amount may not reach the threshold required for action. If property > values in your area continue to decline, you may wish to revisit this issue > again next year.</h3><br /><br />'; > } > elseif(($delco_assess_difference <=30000) && > ($delco_assess_difference>=1000)) { > echo '<h3 style="margin:0;">While it appears you may enjoy some savings, the > dollar amount may not reach the threshold required for action. If property > values in your area continue to decline, you may wish to revisit this issue > again next year.</h3><br /><br />'; > } > elseif(($montco_assess_difference <=50000) && > ($montco_assess_difference>=1000)) { > echo '<h3 style="margin:0;">While it appears you may enjoy some savings, the > dollar amount may not reach the threshold required for action. If property > values in your area continue to decline, you may wish to revisit this issue > again next year.</h3><br /><br />'; > } > elseif(isset($chester_assess_difference) <=1000){ You got an error here. isset($var) returns "true" OR "false", which equals 1 OR 0. You might not compare it with your integer 1000, because it's always smaller. correct would be: elseif (isset($chester_assess_difference) && $chester_assess_difference <= 1000) { // do something } > echo '<h3 style="margin:0;">NO, Your property does not appear to qualify. If > property values in your area continue to decline, you may wish to revisit > this issue again next year. </h3><br /><br />'; > } > elseif(isset($delco_assess_difference) <=1000){ same here > echo '<h3 style="margin:0;">NO, Your property does not appear to qualify. If > property values in your area continue to decline, you may wish to revisit > this issue again next year. </h3><br /><br />'; > } > elseif(isset($montco_assess_difference) <=1000){ and here Regards, Jan PS: The tip no "never use elseif" isn't a good tip, as Robert Cummings pointed out. I second that. > echo '<h3 style="margin:0;">NO, Your property does not appear to qualify. If > property values in your area continue to decline, you may wish to revisit > this issue again next year. </h3><br /><br />'; > } > > echo "chester $chester_ratio .''. $chester_correct_assess .''. > $chester_percent_savings<br/>"; > echo "montco $montco_ratio.''. $montco_correct_assess .''. > $montco_percent_savings<br />"; > echo "delco $delco_ratio .''. $delco_correct_assess.''. > $delco_percent_savings<br />"; > > echo "$county"; > ?> > > > > ""Gary"" <gwpaul@xxxxxxx> wrote in message > news:50.AA.57065.A8A3FF94@xxxxxxxxxxxxxxx >>I am trying to get this to work, however it only reads the second if >>statement. I get no error messages, but as I change counties, the % stays >>the same. >> >> Can someone enlighten me, or should I be looking at switch statements? >> >> Thanks for your help. >> >> Gary >> >> >> >> <?php >> $_SESSION['sale_session']=$_POST['sale']; >> $_SESSION['assess_session']=$_POST['assess']; >> $_SESSION['county_session']=$_POST['county']; >> >> // checks if bot >> if ($_POST['address'] != '' ){ >> exit("Changed field"); >> } >> >> >> $sale_value=$_POST['sale']; >> $assess_value=$_POST['assess']; >> $county=$_POST['county']; >> >> $chester_ratio=.51; >> $montco_ratio=.53; >> $delco_ratio=.58; >> /*$ratio=.51; >> >> >> /*$correct_assess=($sale_value)*($ratio); this is now the assessment >> should be */ >> $chester_correct_assess=($sale_value)*($chester_ratio); >> $montco_correct_assess=($sale_value)*($montco_ratio); >> $delco_correct_assess=($sale_value)*($delco_ratio); >> >> >> $chester_assess_difference=($assess_value)-($chester_correct_assess); >> $montco_assess_difference=($assess_value)-($montco_correct_assess); >> $delco_assess_difference=($assess_value)-($delco_correct_assess); >> >> /* $assess_difference=($assess_value)-($sale_value * $ratio); >> $percent_difference=($assess_difference)/($assess_value);*/ >> $chester_percent_difference=($chester_assess_difference)/($assess_value); >> $delco_percent_difference=($delco_assess_difference)/($assess_value); >> $montco_percent_difference=($montco_assess_difference)/($assess_value); >> >> $chester_percent_savings=($chester_percent_difference)*100; >> $delco_percent_savings=($delco_percent_difference)*100; >> $montco_percent_savings=($montco_percent_difference)*100; >> >> if(($_COOKIE['county_cookie'] ='Chester') && ($chester_assess_difference >> >=50000)) >> >> { >> echo '<h2 style="margin:0;color:#ff0000;">Yes, Your property appears to >> qualify!</h2><br /><br />'; >> echo "You 1 believe your home would today sell for <b> >> $".number_format($sale_value)." </b><br />"; >> echo "Your current tax assessment is<b> >> $".number_format($assess_value)."</b><br />"; >> echo "You live in <b>$county </b><br />"; >> echo "Your potential savings could be<b> " >> .number_format($chester_percent_savings,0)."%</b><br /><br />"; >> echo "According to preliminary calculations based on the information you >> have entered, you may enjoy a savings of <b> >> ".number_format($chester_percent_savings,0)."% </b>off a combined total of >> county, school and township real estate taxes. Actual dollar amount >> savings will differ depending on the township that the property is >> located. Please contact my office for a more precise estimate of >> savings.<br />"; >> >> } >> elseif(($_COOKIE['county_cookie']='Delaware') && ($delco_assess_difference >> >=30000)) { >> >> >> echo '<h2 style="margin:0;color:#ff0000;">Yes, Your property appears to >> qualify!</h2><br /><br />'; >> echo "You 2 believe your home would today sell for <b> >> $".number_format($sale_value)." </b><br />"; >> echo "Your current tax assessment is<b> >> $".number_format($assess_value)."</b><br />"; >> echo "You live in <b>$county </b><br />"; >> echo "Your potential savings could be<b> " >> .number_format($delco_percent_savings,0)."%</b><br /><br />"; >> echo "According to preliminary calculations based on the information you >> have entered, you may enjoy a savings of <b> >> ".number_format($delco_percent_savings,0)."% </b>off a combined total of >> county, school and township real estate taxes. Actual dollar amount >> savings will differ depending on the township that the property is >> located. Please contact my office for a more precise estimate of >> savings.<br />"; >> } >> elseif(($_COOKIE['county_cookie']='Montgomery') && >> ($montco_assess_difference >=50000)) >> >> { >> echo '<h2 style="margin:0;color:#ff0000;">Yes, Your property appears to >> qualify!</h2><br /><br />'; >> echo "You 3 believe your home would today sell for <b> >> $".number_format($sale_value)." </b><br />"; >> echo "Your current tax assessment is<b> >> $".number_format($assess_value)."</b><br />"; >> echo "You live in <b>$county </b><br />"; >> echo "Your potential savings could be<b> " >> .number_format($montco_percent_savings,0)."%</b><br /><br />"; >> echo "According to preliminary calculations based on the information you >> have entered, you may enjoy a savings of <b> >> ".number_format($montco_percent_savings,0)."% </b>off a combined total of >> county, school and township real estate taxes. Actual dollar amount >> savings will differ depending on the township that the property is >> located. Please contact my office for a more precise estimate of >> savings.<br />"; >> } >> >> else if(($chester_assess_difference <=50000) && >> ($chester_assess_difference>=1000)) { >> echo '<h3 style="margin:0;">While it appears you may enjoy some savings, >> the dollar amount may not reach the threshold required for action. If >> property values in your area continue to decline, you may wish to revisit >> this issue again next year.</h3><br /><br />'; >> } >> else if(($delco_assess_difference <=30000) && >> ($delco_assess_difference>=1000)) { >> echo '<h3 style="margin:0;">While it appears you may enjoy some savings, >> the dollar amount may not reach the threshold required for action. If >> property values in your area continue to decline, you may wish to revisit >> this issue again next year.</h3><br /><br />'; >> } >> else if(($montco_assess_difference <=50000) && >> ($montco_assess_difference>=1000)) { >> echo '<h3 style="margin:0;">While it appears you may enjoy some savings, >> the dollar amount may not reach the threshold required for action. If >> property values in your area continue to decline, you may wish to revisit >> this issue again next year.</h3><br /><br />'; >> } >> else if(isset($chester_assess_difference) <=1000){ >> echo '<h3 style="margin:0;">NO, Your property does not appear to qualify. >> If property values in your area continue to decline, you may wish to >> revisit this issue again next year. </h3><br /><br />'; >> } >> else if(isset($delco_assess_difference) <=1000){ >> echo '<h3 style="margin:0;">NO, Your property does not appear to qualify. >> If property values in your area continue to decline, you may wish to >> revisit this issue again next year. </h3><br /><br />'; >> } >> else if(isset($montco_assess_difference) <=1000){ >> echo '<h3 style="margin:0;">NO, Your property does not appear to qualify. >> If property values in your area continue to decline, you may wish to >> revisit this issue again next year. </h3><br /><br />'; >> } >> /*This is just a test to see which one is being displayed*/ >> echo "chester $chester_ratio .''. $chester_correct_assess .''. >> $chester_percent_savings<br/>"; >> echo "montco $montco_ratio.''. $montco_correct_assess .''. >> $montco_percent_savings<br />"; >> echo "delco $delco_ratio .''. $delco_correct_assess.''. >> $delco_percent_savings"; >> ?> >> >> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php