-1

Below is a simple progress bar module I'm trying to create.

    <?php
$progress = 3;

if($progress = 2) {
echo "<pre>progress 2";
var_dump($progress);
echo "</pre><br>";
    $progressPrint = "
    <div class='one progressBar'></div>
    <div class='two progressBar'></div>
    ";echo $progressPrint;
}
elseif($progress = 3) {
echo "<pre>progress3";
var_dump($progress);
echo "</pre><br>";
    $progressPrint = "
    <div class='one progressBar'></div>
    <div class='two progressBar'></div>
    <div class='three progressBar'></div>
    ";echo $progressPrint;
}
elseif($progress = 4) {
    $progressPrint = "
    <div class='one progressBar progressBar'></div>
    <div class='two progressBar'></div>
    <div class='three progressBar'></div>
    <div class='four progressBar'></div>
    ";echo $progressPrint;
}
else {
    echo "nothing";
}

?>

The way it is set up for testing is a manual input of the $progress variable. From there I'm testing against that integer. For some reason I can't get it to read to the $progressBar == 3 elseif.

The var dump shows we're sticking in 2 when the variable is clearly 3.

user3135730
  • 320
  • 1
  • 3
  • 8
  • You're assigning `if($progress =` instead of comparing `if($progress ==`. You even wrote it yourself below your code: *"For some reason I can't get it to read to the `$progressBar == 3`"*. Now you'll us that you did use `==`. I'm not putting in an answer for this one. It may bite me in the *"you know what"*. – Funk Forty Niner Nov 09 '14 at 18:45
  • Fantastic @Fred-ii- . Yep, did it. So to be clear "==" would be comparative where as "=" is assigning. I'm self taught and use it only when I need it. Just want to be clear for others who run into this problem. I'm sure I'll remember this forever now! – user3135730 Nov 09 '14 at 18:51
  • Shall I make it an answer then to close the question? I had to make sure. Many a time, OP's say they did and you had `$progressBar == 3` in your question under your code which made me raise a brow. – Funk Forty Niner Nov 09 '14 at 18:52
  • You're welcome. The deed has been done, *cheers* – Funk Forty Niner Nov 09 '14 at 18:55

1 Answers1

1

As per OP's wish to close the question and be marked as solved:

You're assigning with all the if($progress = instead of comparing if($progress ==

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141