I keep getting a syntax error in this code and I need a new set of eyes to show me what I am doing wrong. It is coming back and saying that I have an unexpected } on line 36.
<?php
require_once("config.php");
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Create query
$qry=("SELECT * FROM registrants");
$result=mysql_query($qry);
//Run through the records retrieved with the MySQL query.
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
//set a to the first week
$a = 1;
$output .= '<input name="id'. $row[id] . '" type="hidden" value="' . $row[id] . '" />'; //Setup the hidden input so each row has its own id.
$output .= 'Name: ' . $row[f_name] . ' ' . $row[l_name]; //Output the first and last name with a space between them.
$week = explode(",",$row[x]); //Turn row[x] into an array with the explode command, where x is the name of the field
foreach ($week as $w){ //for every item in the array week do the following
//Store the information into the variable output
$output .= 'Week ' . $a .'
<select name="week'. $row[id] . '[]">
<option value="Yes">yes</option>
<option value="No">No</option>
<option value="' . $w .'" selected="selected">' . $w .'</option>
</select>';
$a += 1}; //Increase the count by 1
};
?>
Any help is always appreciated. Also, any recommendations for reading material starting out with PHP and mySQL?