Jump to content

Syntax error


nschmutz

Recommended Posts

I am coming up with a syntax error that I cannot figure out. Could someone point out the obvious to me?

 

<html>

 

<head>

 

</head>

 

 

<p>Please enter the start and end years.</p>

 

 

<form action="schmutz_02_03.php" method="post">

 

 

<?php

 

$finals1974 = array('West Germany',

'Netherlands',

'2-1',

'West Germany');

 

$finals1978 = array('Argentina',

'Netherlands',

'3-1',

'Argentina');

 

$finals1982 = array('Italy',

'West Germany',

'3-1',

'Argentina');

 

$finals1986 = array('Argentina',

'West Germnay',

'3-2',

'Mexico');

 

$finals1990 = array('West Germany',

'Argentina',

'1-0',

'Italy');

 

$finals1994 = array('Brazil',

'Italy',

'3-2',

'U.S.A.');

 

$finals1998 = array('France',

'Brazil',

'3-0',

'France');

 

$finals2002 = array('Brazil',

'Germany',

'2-0',

'S.Korea.Japan');

 

$finals2006 = array('Italy',

'France',

'5-3',

'Germany');

 

 

 

if (isset( $_POST[ 'year' ] ))

{

$yearEnt = $_POST['year'];

//not sure how to include the $finals array into the $years array

 

$years = array ('1974' => $finals1974,

'1978' => $finals1978,

'1982' => $finals1982,

'1986' => $finals1986,

'1990' => $finals1990,

'1994' => $finals1994,

'1998' => $finals1998,

'2002' => $finals2002,

'2006' => $finals2006);

 

$remainder = ($yearEnt - 1974) % 4;

 

if(isset($_POST['start']) && isset($_POST['end']))

 

$start = $_POST['start'];

$end = $_POST['end'];

 

 

if($end < $start)

{

echo "End start year should be less than or equal to the end year!</br>";

}

 

for ($i=$_POST['start']; $i <= $_POST['end']; $i = $i + 4)

 

 

foreach ($years as $key=> $value)

{

//echo winner for that year

 

if ($key = $i)

{

echo "The FIFA World Cup champions in $yearEnt were <b>" . $years[$yearEnt][0] . "</b>.\n

They beat <b>" . $years[$yearEnt][1] . "</b>, with a score of <b>" . $years[$yearEnt][2] . "</b>.\n

The finals were hosted by <b>" . $years[$yearEnt][3] . "</b>.</br>";

 

}

}

 

}

 

 

echo 'Start year: <select name="start" value="$start">';

 

foreach ($start as $key => $value)

{

if ($key == $_POST['start'])

{

echo "<option value=\"$key\" selected=\"selected\">$value</option>";

}

else

{

echo "<option value=\"$key\">$value</option>";

}

}

 

echo '</select>';

 

 

echo 'End year: <select name="end" value"$end">';

 

foreach ($end as $key => $value)

{

if ($key == $_POST['end'])

{

 

echo "<option value=\"$key\" selected=\"selected\">$value</option>";

}

else

{

echo "<option value=\"$key\">$value</option>";

}

}

 

echo '</select>';

 

 

echo '<input type="submit" name="submit" value="Go!" />';

 

 

?>

 

</form>

 

</html>

Link to comment
https://forums.phpfreaks.com/topic/205438-syntax-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.