samedi 21 novembre 2015

PHP Variable Value Change Using IF

I am having an issue with my variables value after the IF function. I am looking to change the value of the variable depending on the outcome value of $answer1 on the sender page. However, when I print $answer1 after the IF process, the value has not changed. Before IF it is 5, after the IF process, the Print still produces a 5.

Please can someone advise me how I can increment/decrement using the IF function and affect the value of $answer1 afterwards.

Thank you.

<?php
    $finalvalue=5;

    $answer1=$_GET['answer1'];

    if ($answer1=="1"){$finalvalue+2;}
    elseif ($answer1=="2"){$finalvalue+1;}
    elseif ($answer1=="3"){$finalvalue-1;}
    elseif ($answer1=="4"){$finalvalue-2;};
    print "$finalvalue"
?>

Aucun commentaire:

Enregistrer un commentaire