FORMS WITH MULTIPLE CHECK BOX CHOICES? HOW TO STORE/DISPLAY

Hello guys,

I got a form with the following multi-check box options:

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

They get stored into the database by a .PHP that has:
[php] function procEditAccount(){
global $session, $form;
/* Account edit attempt */
$retval = $session->editAccount($_POST[‘workdays’]);
[/php]

And its retreived like this:
[php]echo “<span class=“blackfont”>Work Days: “.$req_user_info[‘workdays’].”
”;[/php]

But it gets stored in the database as “Array”, meaning… the word Array, not even mon or tues or anything, it just says Array… How can i fix that?

And also, how can i make it so when the user goes to edit their account, it has checked the days that were checked by the time of editing the profile?

Ok guys!

I managed to get the data stored in the database as an array by using serialize($_POST[‘workdays’]), it looks like this after a test:

a:4:{i:0;s:6:"Mon - ";i:1;s:6:"Wed - ";i:2;s:6:"Fri - ";i:3;s:6:"Sat - ";}

Now i just need to know how to echo that thing into my userprofile.php page,

I was normally doing it like this:
[php] echo “<span class=“pinkfont”>Work Days: “.$req_user_info[‘workdays’].”
”;
[/php]

PROBLEM SOLVED

[php]$mydata = unserialize($req_user_info[‘workdays’]);

$itemcount = count($mydata);

echo 'Services: ';
for ($i=0;$i<$itemcount;$i++) {
echo $mydata[$i] . ’ ';
}[/php]

Now the only thing i need to know is how to make those check boxes stay checked by the time the user goes back to edit the profile??

Its gotta be something like this:

<input name=“workdays[]” type=“checkbox” value=“Mon” <?php if($form->value("workdays") == ""){ echo 'checked="checked"';} ?> /> Monday

But remember i have 7 check boxes with the same input name… ughhhhh its driving me crazy :o :o :o :o :-\ :-\ :-X :-X :-[ :-[

Sponsor our Newsletter | Privacy Policy | Terms of Service