hello guys.. i have made a form in checkbox which is in fieldset by categories.. so now the values is success inserted into database.. but i've got problem to make it displayed. The form will pass value YES if user select from form.

if user select a checkbox at form. then value "YES" only have to be displayed..but how to make it?:'(

here my code for checkbox form:

<form id="form1" name="form1" method="post" action="redirect_1.php">

<ul class="checkbox">
                              <input name="BMK81A" type="checkbox" value="YES"/> <label for="BMK81A">BMK81A</label>&nbsp;&nbsp;&nbsp;
                              <input type="checkbox" name="BMK81"  value="YES" /><label for="BMK81">BMK81</label>&nbsp;&nbsp;&nbsp;&nbsp;
                              <input type="checkbox" name="DL3"    value="YES" /><label for="DL3">JPN-DL-3 / JPN-DL-4</label>&nbsp;&nbsp;&nbsp;&nbsp;
                              <input type="checkbox" name="DL2"    value="YES" /><label for="DL2">JPN-DL-2</label>&nbsp;&nbsp;&nbsp;&nbsp;
                              <input type="checkbox" name="DL1"    value="YES" /><label for="DL1">JPN-DL-1</label><br>&nbsp;&nbsp;&nbsp;&nbsp; <br>
                              <input type="checkbox" name="UDSP"   value="YES" /><label for="UDSP>">UDSP</label>
                    </ul>
                    <br>           
                    </td>
          </tr><br> 
        <br>



          <tr>
          <td height="36" bgcolor="#A4DDED" class="style21">
                <fieldset class="group"> 
                    <legend>PEMOHON</legend> 
                    <ul class="checkbox"> 
                          <li><input type="checkbox" name="SSK" value="YES" /><label for="SSK">SSK</label></li> 
                          <li><input type="checkbox" name="PM" value="YES" /><label for="PM">PM</label></li> 
                          <li><input type="checkbox" name="PP" value="YES" /><label for="PP">PP</label></li> 
                          <li><input type="checkbox" name="PT" value="YES" /><label for="PT">PT</label></li> 
                          <li><input type="checkbox" name="AT" value="YES" /><label for="AT">AT</label></li> 
                          <li><input type="checkbox" name="SAA" value="YES" /><label for="SAA">SAA</label></li> 
                          <li><input type="checkbox" name="BW" value="YES" /><label for="BW">BW</label></li>
                          <li><input type="checkbox" name="DS" value="YES" /><label for="DS">DS</label></li> 
                          <li><input type="checkbox" name="APP" value="YES" /><label for="APP">APP</label></li> 
                          <li><input type="checkbox" name="RE1" value="YES" /><label for="RE1">RE1</label></li> 
                          <li><input type="checkbox" name="LU2" value="YES" /><label for="LU2">LU2</label></li> 
                          <li><input type="checkbox" name="NPT" value="YES" /><label for="NPT">NPT</label></li> 
                          <li><input type="checkbox" name="SRP" value="YES" /><label for="SRP">SRP</label></li> 
                          <li><input type="checkbox" name="KDP" value="YES" /><label for="KDP">KDP</label></li>
                    </ul> 
              </fieldset>
          </td>
          </tr>


          <tr>
            <td height="37" bgcolor="#A4DDED" class="style21">
                     <fieldset class="group"> 
                            <legend>PENGANJUR</legend> 
                                    <ul class="checkbox"> 
                                      <li><input type="checkbox" name="KTDP" value="YES" /><label for="KTDP">KTDP</label></li> 
                                    </ul> 
              </fieldset> 
            </td>
            </tr>




          <tr>
            <td height="30" bgcolor="#A4DDED" class="style21">
                                <fieldset class="group"> 
                                        <legend>PENJAGA</legend> 
                                            <ul class="checkbox"> 

                                                  <li><input type="checkbox" name="SSK_9" value="YES" /><label for="SSK_9">SSK</label></li> 
                                                  <li><input type="checkbox" name="SSW_9" value="YES" /><label for="SSW_9">SSW</label></li> 
                                                  <li><input type="checkbox" name="PM_9"  value="YES" /><label for="PM_9">PM</label></li> 
                                                  <li><input type="checkbox" name="PP_9"  value="YES" /><label for="PP_9">PP</label></li> 
                                                  <li><input type="checkbox" name="KP_9a" value="YES" /><label for="KP_9a">KP</label></li> 
                                            </ul> 
                                </fieldset> 
            </td>
               </tr>



          <tr>
            <td height="36" bgcolor="#A4DDED" class="style21">
                            <fieldset class="group"> 
                                <legend>IBU</legend> 
                                        <ul class="checkbox"> 
                                          <li><input type="checkbox" name="SSW1" value="YES" /><label for="SSW1">SSW</label></li> 
                                          <li><input type="checkbox" name="SSK1" value="YES" /><label for="SSK1">SSK</label></li> 
                                          <li><input type="checkbox" name="PM1"  value="YES" /><label for="PM1">PM</label></li>
                                          <li><input type="checkbox" name="PP1"  value="YES" /><label for="PP1">PP</label></li>  
                                          <li><input type="checkbox" name="KP1"  value="YES" /><label for="KP1">KP</label></li> 
                                          <li><input type="checkbox" name="SK1"  value="YES" /><label for="SK1">SK</label></li> 
                                          <li><input type="checkbox" name="SPK1" value="YES" /><label for="SPK1">SPK</label></li> 
                                          <li><input type="checkbox" name="SPC1" value="YES" /><label for="SPC1">SPC</label></li>
                                          <li><input type="checkbox" name="AS1"  value="YES" /><label for="AS1">AS</label></li>  
                                        </ul> 
                            </fieldset>      
            </td>
                  </tr>

                  <tr>
                        <td height="37" bgcolor="#A4DDED" class="style21">
                                <fieldset class="group"> 
                                    <legend>BAPA</legend> 
                                        <ul class="checkbox"> 
                                          <li><input type="checkbox" name="SSW3_a" value="YES" /><label for="SSW3_a">SSW</label></li> 
                                          <li><input type="checkbox" name="SSK3_a" value="YES" /><label for="SSK3_a">SSK</label></li> 
                                          <li><input type="checkbox" name="PM3_a"  value="YES" /><label for="PM3_a">PM</label></li> 
                                          <li><input type="checkbox" name="PP3_a"  value="YES" /><label for="PP3_a">PP</label></li> 
                                          <li><input type="checkbox" name="KP3_a"  value="YES" /><label for="KP3_a">KP</label></li> 
                                          <li><input type="checkbox" name="SK3_a"  value="YES" /><label for="SK3_a">SK</label></li>
                                          <li><input type="checkbox" name="SPK3_a" value="YES" /><label for="SPK3_a">SPK</label></li> 
                                          <li><input type="checkbox" name="SPC3_a" value="YES" /><label for="SPC3_a">SPC</label></li> 
                                          <li><input type="checkbox" name="AS3_a"  value="YES" /><label for="AS3_a">ASh</label></li>  
                                        </ul> 
                                </fieldset> 
                        </td>
                  </tr>



          <tr>
            <td height="36" bgcolor="#A4DDED" class="style21">
                        <fieldset class="group"> 
                            <legend>SUAMI</legend> 
                                <ul class="checkbox"> 
                                      <li><input type="checkbox" name="SSK8" value="YES" /><label for="SSK8">SK</label></li> 
                                      <li><input type="checkbox" name="PM8" value="YES" /><label for="PM8">PMk</label></li> 
                                      <li><input type="checkbox" name="PP8" value="YES" /><label for="PP8">PP</label></li> 
                                      <li><input type="checkbox" name="KP8" value="YES" /><label for="KP8">KP</label></li> 
                                      <li><input type="checkbox" name="SK8" value="YES" /><label for="SK8">SK</label></li> 
                                      <li><input type="checkbox" name="SPK8" value="YES" /><label for="SPK8">SPK</label></li>
                                      <li><input type="checkbox" name="SPC8" value="YES" /><label for="SPC8">SPC</label></li> 
                                      <li><input type="checkbox" name="AS8"  value="YES" /><label for="AS8">AS</label></li>  
                                </ul> 
                        </fieldset> 
            </td>
              </tr>

          <tr>
            <td height="37" bgcolor="#A4DDED" class="style21">
                            <fieldset class="group"> 
                            <legend>ISTERI</legend> 
                                <ul class="checkbox"> 
                                      <li><input type="checkbox" name="SSK6a" value="YES" /><label for="SSK6a">SSK</label></li> 
                                      <li><input type="checkbox" name="PM6a" value="YES" /><label for="PM6a">PM</label></li> 
                                      <li><input type="checkbox" name="PP6a" value="YES" /><label for="PP6a">PP</label></li> 
                                      <li><input type="checkbox" name="KP6a" value="YES" /><label for="KP6a">KP</label></li> 
                                      <li><input type="checkbox" name="SK6a" value="YES" /><label for="SK6a">SK</label></li> 
                                      <li><input type="checkbox" name="SPK6a" value="YES" /><label for="SPK6a">SPK</label></li>
                                      <li><input type="checkbox" name="SPC6a" value="YES" /><label for="SPC6a">SPC</label></li> 
                                      <li><input type="checkbox" name="AS6a"  value="YES" /><label for="AS6a">AS</label></li>  
                                </ul> 
                        </fieldset> 
            </td>
          </tr>

              <tr>
                <td height="36" bgcolor="#A4DDED" class="style21">
                        <fieldset class="group"> 
                            <legend>ADIK BERADIK</legend> 
                                <ul class="checkbox"> 
                                      <li><input type="checkbox" name="SSK_5" value="YES" /><label for="SSK_5">SSK</label></li> 
                                      <li><input type="checkbox" name="PM_5"  value="YES" /><label for="PM_5">PM</label></li> 
                                      <li><input type="checkbox" name="PP_5"  value="YES" /><label for="PP_5">PP</label></li> 
                                      <li><input type="checkbox" name="KP_5"  value="YES" /><label for="KP_5">KP</label></li> 
                                      <li><input type="checkbox" name="SK_5"  value="YES" /><label for="SK_5">SK</label></li> 
                                </ul> 
                        </fieldset> 
                </td>
              </tr>

          <tr>
                <td height="37" bgcolor="#A4DDED" class="style21">
                        <fieldset class="group"> 
                            <legend>ANAK-ANAK</legend> 
                                <ul class="checkbox"> 
                                      <li><input type="checkbox" name="SSK2" value="YES" /><label for="SSK2">SSK</label></li> 
                                      <li><input type="checkbox" name="PM2" value="YES" /><label for="PM2">PM</label></li> 
                                      <li><input type="checkbox" name="PP2" value="YES" /><label for="PP2">PP</label></li> 
                                      <li><input type="checkbox" name="KP2" value="YES" /><label for="KP2">KP</label></li> 
                                </ul> 
                        </fieldset> 
                </td>
          </tr>

now the code for the data inserted into database:

<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
 include('conn.php');
 include('connect2.php');



        // untuk nama table 
        $IC2 = $_SESSION['IC2'];

       $BMK81A = $_POST['BMK81A'];
        $BMK81 = $_POST['BMK81'];
        $DL3 = $_POST['DL3'];
        $DL2 = $_POST['DL2'];
        $DL1 = $_POST['DL1'];
        $UDSP = $_POST['UDSP'];

        // untuk nama table 
        $SSK = $_POST['SSK'];
        $PM = $_POST['PM'];
        $PP = $_POST['PP'];
        $PT = $_POST['PT'];
        $AT = $_POST['AT'];
        $SAA = $_POST['SAA'];
        $BW = $_POST['BW'];
        $DS = $_POST['DS'];
        $RE1 = $_POST['RE1'];
        $KDP = $_POST['KDP'];
        $LU2 = $_POST['LU2'];
        $SRP = $_POST['SRP'];
        $NPT = $_POST['NPT'];
        $APP = $_POST['APP'];



        // untuk nama table 
        $SSK1 = $_POST['SSK1'];
        $SSW1 = $_POST['SSW1'];
        $PM1 = $_POST['PM1'];
        $PP1 = $_POST['PP1'];
        $SK1 = $_POST['SK1'];
        $SPK1 = $_POST['SPK1'];
        $SPC1 = $_POST['SPC1'];
        $AS1 = $_POST['AS1'];
        $KP1 = $_POST['KP1'];

        // untuk nama table
        $SSK2 = $_POST['SSK2'];
        $PM2 = $_POST['PM2'];
        $PP2 = $_POST['PP2'];
        $KP2 = $_POST['KP2'];


        // Untuk table nama doku_bapa (3)
        $SSK3_a = $_POST['SSK3_a'];
        $SSW3_a = $_POST['SSW3_a'];
        $PM3_a = $_POST['PM3_a'];
        $PP3_a = $_POST['PP3_a'];
        $SK3_a= $_POST['SK3_a'];
        $SPK3_a = $_POST['SPK3_a'];
        $SPC3_a = $_POST['SPC3_a'];
        $AS3_a = $_POST['AS3_a'];
        $KP3_a = $_POST['KP3_a'];


        // untuk nama table 
        $SSK_5 = $_POST['SSK_5'];
        $PM_5 = $_POST['PM_5'];
        $PP_5 = $_POST['PP_5'];
        $KP_5 = $_POST['KP_5'];
        $SK_5 = $_POST['SK_5'];


        //untuk nama table doku_isteri (6a)
        $SSK6a = $_POST['SSK6a'];
        $PM6a = $_POST['PM6a'];
        $PP6a = $_POST['PP6a'];
        $KP6a = $_POST['KP6a'];
        $SK6a = $_POST['SK6a'];
        $SPK6a = $_POST['SPK6a'];
        $SPC6a = $_POST['SPC6a'];
        $AS6a = $_POST['AS6a'];


        // untuk nama table 
        $SSK8 = $_POST['SSK8'];
        $PM8 = $_POST['PM8'];
        $PP8 = $_POST['PP8'];
        $KP8 = $_POST['KP8'];
        $SK8 = $_POST['SK8'];
        $SPK8 = $_POST['SPK8'];
        $SPC8 =  $_POST['SPC8'];
        $AS8 = $_POST['AS8'];

        //Untuk nama table 
        $KTDP = $_POST['KTDP'];


        // untuk nama table d
        $SSK_9 = $_POST['SSK_9'];
        $SSW_9 = $_POST['SSW_9'];
        $PM_9 = $_POST['PM_9'];
        $PP_9 = $_POST['PP_9'];
        $KP_9a = $_POST['KP_9a'];


 //insert into database smile2 = second database

    $insert_data=mysql_query(" INSERT INTO '' (NO_KPT2,BMK81A,BMK81,DL3,DL2,DL1,UDSP) VALUES ('$IC2','$BMK81A','$BMK81','$DL3','$DL2','$DL1','$UDSP') ") or die(mysql_error());

    $insert_data1=mysql_query(" INSERT INTO '' (SSK,PM,PP,PT,AT,SAA,BW,DS,APP,RE1,LU2,NPT,SRP,KDP) VALUES ('$SSK','$PM','$PP','$PT','$AT','$SAA','$BW','$DS','$APP','$RE1','$LU2','$NPT','$SRP','$KDP') ") or die(mysql_error());


 $insert_data2=mysql_query(" INSERT INTO '' (SSW1,SSK1,PM1,PP1,KP1,SK1,SPK1,SPC1,AS1,NO_KPT2) VALUES ('$SSW1', '$SSK1' , '$PM1' , '$PP1' , '$KP1' , '$SK1' , '$SPK1' ,'$SPC1' , '$AS1' , '$IC2') ") or die(mysql_error());


     $insert_data3=mysql_query(" INSERT into ''' (SSW3_a,SSK3_a,PM3_a,PP3_a,KP3_a,SK3_a,SPK3_a,SPC3_a,AS3_a,NO_KPT2) VALUES ('$SSW3_a',' $SSK3_a','$PM3_a','$PP3_a',' $KP3_a','$SK3_a','$SPK3_a ','$SPC3_a','$AS3_a','$IC2') ")
     or die(mysql_error());



    $insert_data4=mysql_query(" INSERT into '' (KTDP,NO_KPT2) VALUES ('$KTDP','$IC2') ") or die(mysql_error());



 $insert_data5=mysql_query(" INSERT INTO '' (SSK_5,PM_5,PP_5,KP_5,SK_5,NO_KPT2) VALUES ('$SSK_5' , '$PM_5' , '$PP_5' , '$KP_5' , '$SK_5' , '$IC2') ")or die(mysql_error());



    $insert_data6=mysql_query(" INSERT INTO '' (SSK8,PM8,PP8,KP8,SK8,SPK8,SPC8,AS8,NO_KPT2) VALUES ('$SSK8','$PM8','$PP8','$KP8','$SK8','$SPK8','$SPC8','$AS8','$IC2') ")
     or die(mysql_error()); 



    $insert_data7=mysql_query(" INSERT INTO '' (SSK6a,PM6a,PP6a,KP6a,SK6a,SPK6a,SPC6a,AS6a,NO_KPT2) VALUES ('$SSK6a','$PM6a','$PP6a','$KP6a','$SK6a','$SPK6a','$SPC6a','$AS6a','$IC2') ") or die(mysql_error());    



    $insert_data8=mysql_query(" INSERT into '' (SSK2,PM2,PP2,KP2,NO_KPT2) VALUES ('$SSK2','$PM2','$PP2','$KP2','$IC2') ") or die(mysql_error());    



     $insert_data8=mysql_query(" INSERT into '' SET SSK2='$SSK2' , PM2='$PM2', PP2='$PP2', KP2='$KP2', NO_KPT2 = '$IC2') ") or die(mysql_error());  


    $insert_data9=mysql_query(" INSERT INTO '' (SSK_9 , SSW_9 , PM_9 , PP_9 , KP_9a , NO_KPT2) VALUES ('$SSK_9' , '$SSW_9' , '$PM_9' , '$PP_9' , '$KP_9a' , '$IC2') ")
     or die(mysql_error());

     $insert_data9=mysql_query(" INSERT INTO '' SET SSK_9='$SSK_9', SSW_9='$SSW_9', PM_9='$PM_9', PP_9='$PP_9', KP_9a='KP_9a', NO_KPT2='$IC2' ")
     or die(mysql_error());

 header("");
 ?> 

the problem how to make it if checkbox has been selected and inserted into database AND make it displayed in fieldset by categories? please help me guys...i really need your help..:'(

It is a lot of code here :-). Basically what you have to do is you have to read the data that is already in the database and check for it within the code to see which checkboxes you have to set. From the number of queries in the script I suspect there are many tables but it is not evident from the code. This is why it is hard to give you any examples of select statements.

Other notes:
- maybe you should try to reorganize your code (or approach) so you don't get code that is too hard to manage
- before inserting user supplied values into database you should validate/sanitize them otherwise you have a security issue here

I hope I got the question right :-)

I may be totally off on your question but to me it seems like you want to display "yes" if a check box has been checked and the check boxes that were checked were sucessfully stored in the database. Is that correct? Where do you want to show "yes" at? From what I read above it seems you could set an if for the check boxes in the html where you display them and query the database at the beginning of the code, and fetch all the values from the database(s) you need then just use something like

if ('checkbox1' == 'yes'){
    echo "<p>Yes</p>";
}else{
    echo "<label>Checkbox1</label><input type='checkbox' name='checkbox1' value='Yes'>";
}

also i am not sure if you want to but instead of displaying yes you could just redisplay the checkbox and add the "checked" attribute to it to make the checkbox already checked. That is almost the same code above but just replaying the <p></p> with an input and including "checked" before you close the input. Like I said I am not entirely sure what exactly you want. If you do it all as an array you could make some empty array and make a list of all your input box names and then generate all of them using a foreach loop and also check against for a value matching "yes" using that same foreach and displaying them based on that. Personally the array is the way I would go because you could shorten the code quite a bit.

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.