Location: PHPKode > projects > MyDB > webide/ffrootfield.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");  

      if ($fieldtype == "char") {
	/* Ad a field  Char */
              $query = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null" ;
       } elseif ($fieldtype == "text") {
	/* Ad a field blob text */
              $query = "ALTER TABLE $tablename ADD $fieldname TEXT not null" ;
       } elseif ($fieldtype == "int") {
	/* Ad a field type int */
              $query = "ALTER TABLE $tablename ADD $fieldname INT(15) not null" ;
      } elseif ($fieldtype == "float") {
	/* Ad a field type int */
              $query = "ALTER TABLE $tablename ADD $fieldname FLOAT(10,2) not null" ;
      } elseif ($fieldtype == "currencytype") {
			  $query = "ALTER TABLE $tablename ADD $fieldname FLOAT(10,2) not null";
      } elseif ($fieldtype == "listbox") {
	/* Ad a empty enum field */
			  $query2 = "ALTER TABLE $tablename ADD $fieldname ENUM (' ') not null";
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }  
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'optiontype', 'listbox')" ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
              $urllistbox = "ffeditlistbox.php?fieldname=".$fieldname ;
			  header("Location: $urllistbox"); 
			  exit;
     } elseif ($fieldtype == "date") {
		/* Ad a field type int */
              $query2 = "ALTER TABLE $tablename ADD $fieldname INT(15) not null" ;
	             $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }  
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'datef', 'd/m/Y')" ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
 			  $query4 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'label', '$label') ;" ; 			
		      $rinsertreg = mysql_db_query($conx->db, $query4, $idconx) ; 		  
              $urllistbox = "ffeditfield.php?fieldname=".$fieldname ;
			  header("Location: $urllistbox"); 
			  exit;
 			  
      } elseif ($fieldtype == "listboxt") {
	/* Ad a empty char field */
			  $query2 = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null";
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }  
              $urllistbox = "ffeditlistboxextern.php?fieldname=".$fieldname ;
			  header("Location: $urllistbox"); 
			  exit;
    } elseif ($fieldtype == "caracteristic") {
	/* Ad a empty char field */
	$query2 = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null";
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'caracteristic', '1')" ;
	$rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
              if ($rinsertfield==0) { 
		$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
		header("Location: $urlerror");              
              }  
              $urllistbox = "ffeditlistboxextern.php?fieldname=".$fieldname ;
	header("Location: $urllistbox"); 
	exit;
    } elseif ($fieldtype == "categorie") {
	/* Ad a empty char field */
			  $query2 = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null";
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'categorie', '1')" ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }  
              $urllistbox = "ffeditlistboxextern.php?fieldname=".$fieldname;
			  header("Location: $urllistbox"); 
			  exit;
     } elseif ($fieldtype == "checkbox") {
			$query = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null";
              // echo $query;
            $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'optiontype', 'checkbox')" ;
			$rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
            if ($rinsertreg==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
            }  
             $query4 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'default', '$strYes')" ;
             $rinsertreg = mysql_db_query($conx->db, $query4, $idconx) ;      
             $defaultvalue = $strYes ;
     } elseif ($fieldtype == "radiobutton") {
	/* Ad a empty enum field */
			  $query2 = "ALTER TABLE $tablename ADD $fieldname ENUM (' ') not null";
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'optiontype', 'radiobutton')" ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }  
              $urllistbox = "ffeditradiobutton.php?fieldname=".$fieldname ;
			  header("Location: $urllistbox"); 
			  exit;
     } elseif ($fieldtype == "email") {
	/* Ad a field  Char */
              $query2 = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null" ;
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'email', '1')" ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }              
     } elseif ($fieldtype == "file") {
              $query2 = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null" ;
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'picture', '../dbimage')" ;
			//echo $query3 ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }        
              $urlfile = "ffeditfield.php?fieldname=".$fieldname ;
			  header("Location: $urlfile"); 				        
       } elseif ($fieldtype == "login") {
              $query2 = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null" ;
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'access', 'login') ;" ;
 			  $query4 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'label', '$label') ;" ; 			
			//echo $query3 ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
 		      $rinsertreg = mysql_db_query($conx->db, $query4, $idconx) ;  				  
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }        
              $urlfile = "ffeditfield.php?fieldname=".$fieldname ;
			  header("Location: $urlfile"); 				        
    
   } elseif ($fieldtype == "password") {
              $query2 = "ALTER TABLE $tablename ADD $fieldname CHAR(250) not null" ;
              $rinsertfield = mysql_db_query($conx->db, $query2, $idconx); 
              $query3 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'access', 'password') ;" ;
 			  $query4 = "insert into $conx->registryTable values ('','$tablename', '$fieldname', 'label', '$label') ;" ; 			
			//echo $query3 ;
			  $rinsertreg = mysql_db_query($conx->db, $query3, $idconx) ; 
 		      $rinsertreg = mysql_db_query($conx->db, $query4, $idconx) ;  				  
              if ($rinsertfield==0) { 
				$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
				header("Location: $urlerror");              
              }        
              $urlfile = "ffeditfield.php?fieldname=".$fieldname ;
			  header("Location: $urlfile"); 				        
    }
	
	
	
    if (isset($query)) {
          $rinsertfield = mysql_db_query($conx->db, $query, $idconx); 
            if ($rinsertfield==0) { 
		$urlerror = "./ffdberro.php?errormsg=".urlencode(mysql_error()) ; 
		header("Location: $urlerror");              
          }              
    }



     require("hd_inc.php"); 

?>


         <!---- Debut du contenue de la page principal ---->       

 <FORM method="post" enctype="application/x-www-form-urlencoded" action="ffsavoptions.php">
<INPUT name="label" value="<?php echo stripslashes($label); ?>" type="hidden">
<INPUT name="fieldname" value="<?php echo $fieldname; ?>" type="hidden">
 <INPUT name="MyDB_Session" value="<?php echo $MyDB_Session; ?>" type="hidden">
<?php echo $strLabelDefaultValue; ?> : <INPUT name="default" type="text" value="<? echo $defaultvalue; ?>"><BR>
<?php echo $strLabelRequiredField; ?> : <INPUT name="required" value="yes" type="checkbox"><BR>
<?php echo $strLabelHiddenField; ?>  : <INPUT name="hidden" value="yes" type="checkbox"><BR>
<?php echo $strIsItAnEMailType; ?>  : <INPUT name="emailtype" value="yes" type="checkbox"<?
if ($fieldtype == "email") { echo "checked"; }
?>><BR>
<?php 
 if ($fieldtype == "currencytype") { 
	echo $strIsItAnCurrencyType." : "; 
	$cur = new currency ; 
	$query = "select name from $cur->tbl_currency" ; 
               $rescur = mysql_db_query($conx->db, $query) ; 
	echo "<select name=currencytype>" ; 
	while( list ($name) = mysql_fetch_array($rescur) ) {
		echo "<option>$name</option>"; 	
	} ?>
	</select>
<? } ?>
<BR> 
<BR> 
<?php echo $strFieldLanguage; ?> : <input name="languagetype" type=text size=4><BR>

<INPUT value="<?php echo $strFBSubmitOptions; ?>" type="submit">
 </FORM>            
          
       <!--- Fin du contenue de la page Principale --->         
<?
 include("ft_inc.php"); 
?>


Return current item: MyDB