-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
  • 12,099
  • 6
  • 34
  • 51
0

try this

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

Try

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