-1

I got this simple code:

$x = 1999;
while($x != 1949)
{
    echo '<option value="' $x '">' $x '</option>';
    $x = $x - 1;
}

But the page isn't loading any more with this code, what's wrong with it?

donbingo
  • 29
  • 5

3 Answers3

0

You need to concatenate your variables: (notice the dots in your echo)

$x = 1999;
while($x != 1949)
{
    echo '<option value="'.$x.'">'.$x.'</option>';
    $x = $x - 1;
}
Daan
  • 11,690
  • 6
  • 30
  • 49
0

try this

$x = 1999;
while($x != 1949)
{
    echo '<option value="'. $x .'">'. $x .'</option>';
    $x = $x - 1;
}
Syed mohamed aladeen
  • 6,258
  • 4
  • 28
  • 58
0

Try

$x = 1999;
while($x != 1949)
{
    echo '<option value="'.$x .'">'. $x. '</option>';
    $x--;
}
Dhinju Divakaran
  • 916
  • 1
  • 8
  • 11