//time Am
        $a=$_POST[am];
        $a1=$_POST[am_min];

        $tmeAm=$a.':'.$a1;
        //time AM

        //time Pm
        $p=$_POST['pm'];
        $p5=$_POST['pm_mins'];
        $s=':';
        $times=$p.':'.$p5;

        $ttime=$tmeAm.'-'.$times;
        //days
        $days=$_POST['days'];
        for($i=0;$i<count($days);$i++)
        $dd=$days[$i];

        mysql_query("insert into tc_handle set sid='$_POST[ass]',
        sub_id='$_POST[lvl]',
        secid='$_POST[secs]',
        section='$g_sec[name]',
        year='$g_sub[year]',
        code='$g_sub[code]',
        date='$cur',
        acad_id='$now[acad_id]',
        time='$ttime',room='$_POST[rm]',
       ** days='$dd'-------------------------- having problem here, it only saves the last checkbox in my form, why is it???**
        ")or die (mysql_error());
        $mess="Assigned Sucessfully!";
Code blocks are created by indenting at least 4 spaces
... and can span multiple lines

      here is my form in that checkbox


       <input type="checkbox" name="days[]" id="days[]" value="M"/>
          M
          &nbsp;&nbsp;
          <input type="checkbox" name="days[]" id="days[]"  value="T"/>
          T
          &nbsp;&nbsp;
          <input type="checkbox" name="days[]" id="days[]" value="W"/>
          W
          &nbsp;&nbsp;
          <input type="checkbox" name="days[]"  id="days[]" value="Thu"/>
          Th
          &nbsp;&nbsp;
          <input type="checkbox" name="days[]"  id="days[]" value="Fri"/>

need help urgent! thanks!

You haven't explained what you're trying to do, so I have assumed that you want to insert a comma separated lsit of days into your database field.

The reason only the last day is being saved is because you're overwriting the values in your loop on line 18.

Instead, why not try replacing lines 16 - 18 with:

$days = isset($_POST['days']) ? implode(',', $_POST['days']) : '';

R

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.