html - I need a php code to update my database table with only the options that I have checked -


i have student table checkboxes in front of it. if click promote button, want ones check update in database , rest should not.

here html code :

<table class="table toggle-square" data-filter="#table_search" width="792" border="0" align="center">                           <tr>                             <td width="92" height="26" bgcolor="#fba774"><div align="center"><strong>s/n</strong></div></td>                             <td width="131" bgcolor="#fba774"><div align="center"><strong>reg number</strong></div></td>                             <td width="152" bgcolor="#fba774"><div align="center"><strong>full name</strong></div></td>                             <td width="140" bgcolor="#fba774"><div align="center"><strong>class</strong></div></td>                             <td width="255" bgcolor="#fba774"><div align="center"></div></td>                             <?                                 $i=0;       while ($rowgeneral = mysql_fetch_array($sqldisplayresult)){           $i++;                             //$choice = $rowgeneral['stdcurrentclass'];                             //if ($choice == "14"){                             ?>              <tr>                             <td><div align="center">                               <?=$i?>                             </div></td>                             <td><div align="center"><?=$rowgeneral['stdregnumber']?></div></td>                             <td><div align="center">                               <?                    $stdname = $rowgeneral['stdregnumber'];                   $retrivestdnamequery = mysql_query("select * tb_student_reg regnumber = '$stdname'");                 $stdnamerow = mysql_fetch_array($retrivestdnamequery);                 $mystdname = $stdnamerow['firstname'].' '.$stdnamerow['lastname'].' '.$stdnamerow['middlename'];                               echo $mystdname;                               ?>                             </div></td>                             <td><div align="center">                              <?                    $classid = $rowgeneral['stdcurrentclass'];                  $retriveclassnamequery = mysql_query("select * tb_classes id = $classid");                   $classnamerow = mysql_fetch_array($retriveclassnamequery);                   $classname = $classnamerow['classname'];                               echo $classname;                               ?>                              </div></td>                             <td><div align="center">    <!--<input  type="checkbox" onchange="feetotal"  name="subject[]" value="<?=$rowgeneral['currentclass']?>"     checked onclick="return false">-->      <?                              //echo $rowgeneral['avg_score'] . " >=  ".  $averagescore;                             if ($rowgeneral['avg_score'] >= $averagescore){                             ?>             <input type="checkbox" name="checkbox" id="checkbox" checked>                               <? }                             else{                             ?>                              <input type="checkbox" name="checkbox" id="checkbox" >                             <?                             }?>                             </div></td>                      <? }?>               <tr>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>              <tr>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td>&nbsp;</td>                <td><div align="right">                   <input type="submit" name="promote" id="promote" value="promote">                </div></td>            </table> 

here php code update :

<?    $updatepromotionquery = ""; if(isset($_post['promote'])) {     $promotedclass = $_post['promotedclass'];     $currentclass = $_post['currentclass'];     $checkbox = $_post['checkbox'];   $updatepromotionquery = "update tb_student_reg set promotedclass ='$promotedclass'   currentclass = '$currentclass'";  mysql_query($updatepromotionquery);  }  ?> 

use multi check box

<input type="checkbox" name="checkbox[]"> 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -