Ok, so I used to have hard coded checkboxes. The process looked like this:
//setting checkbox values
if ( ! empty( $portPHPCheck ) )
{
$portPHPCheck = "Y";
} else {
$portPHPCheck = "N";
}
$portDesc = $_POST[welcomeField];
$query = "INSERT INTO portfolio
( portSection, portCompleteDate, portClientName, portWeb, portDesc, portPHPCheck )
VALUES
( '$portSection', '$date', '$portClientName', '$portWeb', '$portDesc', '$portPHPCheck' )";
Nothing mysterious about that. Then I would basically do the reverse to show which boxes were selected during 'edit' mode. No problem. Then, I got the bright idea that my checkboxes should be dynamic. Basically, you're choosing from a list of features in the database, that is managed with the Features table. No problem there. But when you go to select these boxes, I can't figure out how to tell the database what is selected. After this:
<?
$section_data = mysql_query( "SELECT * FROM features ORDER BY featureName" );
while ( $b_row = mysql_fetch_array( $section_data ) ) {
?>
<input type="checkbox" id="feature[]" value="<? print $b_row['featureName']; ?>">
<? print $b_row['featureName']; ?>
<?
}
?>
So lets say the features listed currently include Flash, Html, XML, PHP, ASP. When selecting features for a particular portfolio piece (to be included with the portfolio piece's data in the database) I thought I might just build a string based on which features were selected, and put that into a 'features' field in the portfolio table.
So if Flash, PHP, and HTML were all that was selected, then $string = "Flash PHP HTML" and I can explode the string later to see which features should be checked when I go back to edit that portfolio piece.
But I'm having trouble figuring out how to build that string in the first place. Any ideas?
cheers,
jason