Jump to content

Not adding to array!


zachatk1

Recommended Posts

Here's the code:

 

$year_values = array('Any', 'N/A', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012');
$db_year = explode(', ', $row['YEAR']);

foreach($year_values as $year_value)
{
    $selected_year = null;
    $year_label = $year_value;

    if(in_array($year_value, $db_year))
    {
        $selected_year = ' checked="checked"';
        $year_label = "<b>$year_value</b>";
    }

    echo '<input type="checkbox" name="year" value="' . $year_value . '"' . $selected_year . ' />' . $year_label . ' ';
}
?>
[/code

That pulls the data of the database and puts it in check boxes. The user can check/uncheck certain boxes but  the problem is when it goes to the verify page it has only one value from the array that was selected. On the verify page it just checks if a box was checked and then implodes the array before submitting it into the database.

[code]
$year_s=implode($year,", ");

 

So like I said there is only one value from the array when there should be as many as the user checks. So basically I believe the value isn't added to the array.

Link to comment
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.