Location: PHPKode > projects > MyDB > webide/ffeditcheckbox.php
<?php 
/*************************************************************
 * The MyDB librairy and applications are product of SQLFusion
 * It may be used and/or distributed under the terms of the Q Public
 * License (QPL) version 1.0, enclosed in the file licence.txt.
 ****************************************************************/
/** MyDB IDE Version 0.4    **/ 
/** Author Philippe Lewicki **/

      require("mydbconfig.inc.php");  
  

	$table_def = mysql_db_query($conx->db, "SHOW FIELDS FROM $tablename", $idconx);
	   for ($i=0;$i<mysql_num_rows($table_def);$i++)
	   {
	       $row_table_def = mysql_fetch_array($table_def);
	       $field = $row_table_def["Field"];
                     $FieldType[$field] = $row_table_def["Type"] ;
	   }

	//echo $FieldType[$fieldname] ; 

           $set = ereg_replace("''", "~", $FieldType[$fieldname]);        
            $set = ereg_replace("set\(|enum\(|'|\)", "", $set);
            $setdisp = ereg_replace("~", "'", $set);     
            $set = ereg_replace("~", "'", $set);  
            $setdisp  = explode(",", $setdisp);
            $set = explode(",", $set);

   if ((strlen($newitem)>0) && isset($submitadd)) {
         $query = "ALTER TABLE $tablename CHANGE $fieldname $fieldname ENUM("; 
         for ($j=0; $j<count($set);$j++)
              {
              $query .= "'$set[$j]'," ;
              }
         $query .= "'$newitem') not null" ; 
     //   echo $query ;
        $rupdate = mysql_db_query($conx->db, $query, $idconx) ;
       header("Location: ffeditlistbox.php?fieldname=$fieldname"); 
   }

   if ((strlen($deleteitem)>0) && isset($submitdel)) {
            $i=0 ;
           for ($j=0; $j<count($set);$j++) {
                if ($deleteitem != $set[$j])  {
                        $newset[$i] = $set[$j] ;
                        $i++; 
                }
            } 
         $query = "ALTER TABLE $tablename CHANGE $fieldname $fieldname ENUM("; 
           $query .= "'$newset[0]'" ;
         for ($j=1; $j<count($newset);$j++)
              {
            $query .= ",'$newset[$j]'" ;
              }
         $query .= ") not null" ; 
     //  echo $query ;
        $rupdate = mysql_db_query($conx->db, $query, $idconx) ;
       header("Location: ffeditlistbox.php?fieldname=$fieldname"); 
   }

require("hd_inc.php"); 

?>

         <!---- Debut du contenue de la page principal ---->       
<FORM method="get" enctype="application/x-www-form-urlencoded" action="ffeditlistbox.php">
<table><tr><TD align="right">
<INPUT name="fieldname" value="<?php echo $fieldname; ?>" type="hidden">
             <?php 
          echo "<select name=deleteitem>\n";          
          for ($j=0; $j<count($set);$j++)
              {<INPUT name="test" value="test" type="checkbox">
              echo "<option value=\"$set[$j]\"";
              echo ">$set[$j]";
              }
          echo "</select>";

          ?></td> <td> <INPUT value="Delete" type="submit" name="submitdel"></td></tr>
<tr><TD align="right">  
</form>
<FORM method="get" enctype="application/x-www-form-urlencoded" action="ffeditlistbox.php">
<INPUT name="fieldname" value="<?php echo $fieldname; ?>" type="hidden">

<INPUT name="newitem" type="text">
</td><td>
<INPUT value="Add" type="submit" name="submitadd">
</td></tr>
</table>
          </form>
<BR>
<a href="formbuilder.php">Retour à l'édition du formulaire</a><BR>

       <!--- Fin du contenue de la page Principale --->         

<?php 
 require("ft_inc.php"); 
 ?> 


Return current item: MyDB