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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.