Hi all,
I’m testing a piece of PHP that I am writing to output a TRUE or FALSE statement on a website where my user’s are receiving feedback from other users. The point of this script is to determine if a person’s feedback “score” has increased by more than a set number (in this example, 30) and if so output their status as TRUE otherwise output it as FALSE. (I hope that makes sense).
I thought I’d done everything right but it appears that in my example (see below) the script always outputs FALSE even though the difference is 100 (way above the 30 theshold that has been set.)
Am I missing something really simple here?
<?php
// Retrieve the "Previous Score" - Hardcoded for testing purposes. Replace this with correct syntax for the previous score field in the database when going to production.
$last_score = 0;
echo "Last Score Was $last_score"; ?> <br /> <?php
// Retrive the NEW current score from the Shop's database. Harcoded for testing purposes, replace this with the correct field for the database when going to production.
$new_score = 100;
echo "New Score Is $new_score"; ?> <br /> <?php
// Calculate the differences between the "NEW" score and the "Previous" score.
$feedback_difference = $new_score; - $last_score;
echo "Feedback Difference Is $feedback_difference"; ?> <br /> <?php
// Check if difference is Over 30 and if true update Top Seller status to TRUE otherwise update it to FALSE
$threshold = 30;
if ($feedback_difference >> $threshold) {
$top_seller = 'TRUE'; }
else; {
$top_seller = 'FALSE'; }
echo "Top Seller Status Set To: $top_seller";
?>
Check it out at http://ivegotkids.com/scripts/top_seller.php
The last word should say “TRUE” because in this example, the feedback_difference is 100. Everything else seems to be working but it’s still saying FALSE.