Location: PHPKode > projects > MyDB > mydatalib/mydatalib.inc.php3
<?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.
 ****************************************************************/
/** MyDataLib Version 0.7    **/ 
/** Author Philippe Lewicki **/

   /*
    *  Class mydataConnect
    *  Its used for parameters in the forms génération.
    *  mydatalib.inc.php3 Version : 1.1.016
    *
   */


Class mydataconnect {
  /* Information to connect to the database */
   var $hostname = "localhost"  ;   /*  Name of the host */
   var $login = "lewicki" ;       /* Login to acces the database */
   var $password = "lewicki" ;   /* Password to acces the database */

/* information use by the other class */
   var $db ;        /* Database Name */
   var $table = "";      /* Table Name */
   var $sql_query ;
   var $sql_order ;
   var $pos = 0 ;
   var $max_rows ;       /* number of records to display */
   var $num_rows;      /* Number of the total record of the query */
   var $server ="0";
   var $id;          /* identificateur de connexion (private) */
   var $result ;          /* result of  query  (private) */
   var $insert_id ;       /* num record after an insert  (private) */

  var $registryTable = "registry" ;   /* Name of the registry Table */

        /*
    *  Function start()
    *  Its use to connect to the database.
    *   If you use persistent link to the SQL server or you
    *   already have a connection open in the script
    *  you don't have to  use it.
    *  Change the name to : dbconnect()
   */

function start()  {
    $linkidentifier = mysql_connect($this->hostname, $this->login, $this->password) ;
    $this->id = $linkidentifier;
    return $linkidentifier ;
}
function startp()  {
    $linkidentifier = mysql_pconnect($this->hostname, $this->login, $this->password) ;
    $this->id = $linkidentifier ;
    return $linkidentifier ;
}

function getnum_rows() {
/*
 $this->sql_query = stripslashes($this->sql_query);
$this->sql_order = stripslashes($this->sql_order);

    if ($this->sql_query == "") {
       $this->sql_query= "select * from $this->table" ;
    }

     $rnumrow = mysql_db_query($this->db, $this->sql_query, $this->id) ;
   $this->num_rows = mysql_num_rows($rnumrow) ;
*/
   $this->num_rows = mysql_affected_rows($this->id) ;
    return $this->num_rows ;
}

function query() {
 $this->sql_query = stripslashes($this->sql_query);
$this->sql_order = stripslashes($this->sql_order);

    if ($this->sql_query == "") {
       $this->sql_query= "select * from $this->table" ;
    }
   if (!$this->pos) { $this->pos = 0 ; }
   if ($this->max_rows) {
          $qpos = " limit ".$this->pos.", ".$this->max_rows ;
    } else {
            $qpos = "";
     }
      $rquery = mysql_db_query($this->db,"$this->sql_query $this->sql_order $qpos", $this->id);
      if (!$this->max_rows) {
            $this->num_rows = @mysql_num_rows($rquery) ;
            }
      $this->insert_id = mysql_insert_id() ;
      $this->result = $rquery ;
      return $rquery ;
}

function fetch($result = 0) {
     if ($result>0) {
   $rowobject = mysql_fetch_object($result) ;
      } elseif ($this->result>0) {
   $rowobject = mysql_fetch_object($this->result) ;
   }
   return $rowobject ;
}

function fetcharray($result = 0) {
     if ($result>0) {
   $rowarray = mysql_fetch_array($result) ;
      } elseif ($this->result>0) {
   $rowarray = mysql_fetch_array($this->result) ;
   }
   return $rowarray ;
}

function gettablefield($result=0) {
   if ($result) {
                    $table = mysql_field_table($result,0);
    } elseif ($this->table) {
                    $table = $this->table ;
    }
   $table_def = mysql_db_query($this->db, "SHOW FIELDS FROM $table");
         for ($i=0;$i<mysql_num_rows($table_def);$i++) {
        $row_table_def = mysql_fetch_array($table_def);
        $field[$i] = $row_table_def["Field"];
     }

       reset($field) ;
       return $field ;
}

function free($result = 0) {
  if ($result>0) {
    mysql_free_result($result) ;
  } elseif ($this->result>0) {
    mysql_free_result($this->result) ;
  }
   $this->sql_query ="";
   $this->sql_order ="" ;
   $this->pos = 0 ;
   $this->max_rows = 0 ;
   $this->num_rows = 0;
} 

} /* Fin class mydataconnect */




   /*     Class record()
     It gets informations from a form generate by a form and record it in
   the database.

  */

class mydataRecord {

 var $strPassorwAllReadyUsed = "Mot de passe déja utilisé";
 var $strErrorAccessType = "Vous devez avoir 1 login et 1 mot de passe" ;
 var $strWrongEmail = "L'adresse email que vous avez saisi est invalide" ;
 var $strRequiredField = "Vous devez saisir tous les champs obligatoire ";
 var $strErrorPasswordnotmatch = "Les mots de passe saisie ne correspondent pas "; 
 var $strErrorLoginPasswordAlreadyUsed = "Vous devez choisir un autre login et mot de passe "; 
 var $urlError = "error.php3";
 var $strInsertError = "Erreur lors de l'insertion de l'enregistrement "; 
 
  function save($dbc) {
    global $filechange, $filefield, $userfile, $userfile_name, $fields,  $table, $required ;
	global $emailfield, $primary_key, $requiredURL, $goto, $accessfield, $fieldrepeatpass ;
	global $datefieldname, $datefieldmonth, $datefieldday, $datefieldyear ;


   $idconx = $dbc->id ;

   $no_require = true;

   reset($fields);

	/*****************************
	 * Recompose de date in php/unix format
	 *
	 ****************************/
	 
  $nbrdate = count($datefieldname) ; 	 
  if ($nbrdate>0) {
  	for ($i=0; $i<$nbrdate; $i++) {
	 $tmpdatefieldname = $datefieldname[$i] ; 
	 $fields[$tmpdatefieldname] =  mktime(0,0,0,$datefieldmonth[$tmpdatefieldname], $datefieldday[$tmpdatefieldname], $datefieldyear[$tmpdatefieldname]) ;
	}
  } 	 

   
   /*******************************
    * Login Password vérification 
	* To test if passwords matches and there is not already a login and password
	* To work the uniq id of the table must be named as id<table name>. 
	* If its a new record the uniqid must be an empty string else a integer.
	*******************************/
   
   if (isset($accessfield)) {
    $nbraccess = count($accessfield) ; 
	if ($nbraccess != 2) {
	    $message = $this->strErrorAccessType;
        $urlgoto = $this->urlError."?messageerr=".urlencode($message) ;
        Header("Location: $urlgoto");
		exit ;
	}
	$passwordfield = $accessfield["password"] ;
	$loginfield = $accessfield["login"] ; 
	if ($fields[$passwordfield] != $fieldrepeatpass[$passwordfield]) {
	    $message = $this->strErrorPasswordnotmatch;
        $urlgoto = $this->urlError."?messageerr=".urlencode($message) ;
        Header("Location: $urlgoto");
		exit ;
	}
	$uniqidfield = "id".$table ;
	$queryverif = "select ".$uniqidfield." from ".$table." where ".$passwordfield."='".$fields[$passwordfield]."' and ".$loginfield."='".$fields[$loginfield]."'" ;
    $rverif = mysql_db_query($dbc->db,$queryverif, $dbc->id);
	if (mysql_num_rows($rverif)) {
	     list($uniqidvalue) = mysql_fetch_array($rverif) ;
		 $struniqidfield = sprintf("%d", $fields[$uniqidfield]) ;
		 if ((strlen($fields[$uniqidfield])==0) || !($fields[$uniqidfield] == $uniqidvalue)) {
	      $message = $this->strErrorLoginPasswordAlreadyUsed;
          $urlgoto = $this->urlError."?messageerr=".urlencode($message) ;
          Header("Location: $urlgoto");
		  exit ;	   		
	     }
	}
	   
   }
     /* verify the email adresse */

    $urlerror = $this->urlError ;

   if (isset($emailfield)) {
     $nbremail = count($emailfield) ;
     for ($i=0; $i<$nbremail; $i++) {
           $tmp_emailname = $emailfield[$i] ;
          $val_results =validateEmail( $fields[$tmp_emailname] ) ;
    //    echo "0-".$val_results[0]."<br>"."1-".$val_results[1]."<br>2-".$val_results[2];
          if (($val_results[0] == false) && $required[$tmp_emailname] == "yes") {
              $urlerror .= "?messageerr=".urlencode($this->strWrongEmail).$val_results[1]."&lang=".$lang ;
            header("Location: $urlerror");
      exit;
          }
      }
       reset($emailfield);
    }


     if (isset($primary_key))
   {
   $primary_key = stripslashes($primary_key);

   $valuelist = '';
   while (list($key, $val) = each($fields))
         {
          if (($required[$key]=="yes") && $val == "") {
                   $requiredURL .= "?messageerr=".urlencode($this->strRequiredField);
               header("Location: $requiredURL");
         exit;
      } else {
       for($fidx=0;$fidx<count($filefield);$fidx++) {
          if($filefield[$fidx]==$key && $userfile[$fidx] != "none") {
              if($userfile_name[$fidx]=="") {
                  $val="dd";
              } else {
                $rcon=new mydataconnect;
                // $rcon->start();
				$rcon->id = $dbc->id ;
				$rcon->db = $dbc->db ;
                $rcon->sql_query="select * from registry where rtable='$table' AND rfield='$key' AND rtype='picture'";
                $rcon->query();
                $iname="";
                $ipath="";
                if($fnd=$rcon->fetch()) list($ipath,$iname,$contenttype)=explode(":",$fnd->rdata);
                if($iname!="") $val="n".$primary_key.strrchr($iname,".");
                else $val=$userfile_name[$fidx];
                $destpath="$ipath/$val";
                if(!copy($userfile[$fidx],$destpath)) die("Unable to save $userfile_name[$fidx] on $destpath...");
                break;
              }
          }
        }
          if($val != "null") $val = "'$val'";
          $valuelist .= "$key = $val, ";
      }
         }
      $valuelist = ereg_replace(', $', '', $valuelist);
      $query = "UPDATE $table SET $valuelist WHERE $primary_key";
        $message = urlencode($strUpdateOk) ;
        $update="yes";
      }
   else
      {
      $fieldlist = '';
      $valuelist = '';
      while (list($key, $val) = each($fields))
         {		
           $fieldlist .= "$key, ";
           if (($required[$key]=="yes") && $val == "") {
                $requiredURL .= "?messageerr=".urlencode($this->strRequiredField);
               header("Location: $requiredURL");
         exit;
      } else {

    for($fidx=0;$fidx<count($filefield);$fidx++) {
          if($filefield[$fidx]==$key && $userfile[$fidx] != "none") {
              if($userfile_name[$fidx]=="") {
                  $val="dd";
              } else {
                $rcon=new mydataconnect;
               // $rcon->start();
				$rcon->id = $dbc->id ;
				$rcon->db = $dbc->db ;				
                $rcon->sql_query="select * from registry where rtable='$table' AND rfield='$key' AND rtype='picture'";
                $rcon->query();
                $iname="";
                $ipath="";
                if($fnd=$rcon->fetch()) list($ipath,$iname,$contenttype)=explode(":",$fnd->rdata);
                if($iname!="") $val="n".strrchr($iname,".");
                else $val=$userfile_name[$fidx];
                $destpath="$ipath/$val";
                if(!copy($userfile[$fidx],$destpath)) die("Unable to save $userfile_name[$fidx] on $destpath...");
                break;
              }
          }
        }

               if ($val != "null")
               $val = "'$val'";
               $valuelist .= "$val, ";
            }
         }
      $fieldlist = ereg_replace(', $', '', $fieldlist);
      $valuelist = ereg_replace(', $', '', $valuelist);
      $query = "INSERT INTO $table ($fieldlist) VALUES ($valuelist)";

        $message = urlencode($strInsertOk) ;
        $update = "no" ;
      }
      $sql_query = $query;

      $result = mysql_db_query($dbc->db, $query, $idconx);
      $uniqid = mysql_insert_id() ;

   if (!$result)
      {
      $error = mysql_error();
      $message = urlencode($this->strInsertError.$error) ;
        if (ereg('\?',$urlerror)) {
              $urlgoto = $urlerror."&messageerr=".$message ;
              } else {
              $urlgoto = $urlerror."?messageerr=".$message ;
              }
      Header("Location: $urlgoto");

      }
   else
      {
         $message = urlencode($strInsertOk) ;
        if (ereg("\?",$goto)) {
              $urlgoto = $goto."&messageok=".$message."&update=".$update."&insertid=".$uniqid ;
              } else {
              $urlgoto = $goto."?messageok=".$message."&update=".$update."&insertid=".$uniqid ;
              }
      Header("Location: $urlgoto");
       }


  }

}
   /*
    *  Class mydataForm
    *  Its used for parameters in the forms génération.
    *
    *
    *
   */

Class mydataForm {

  /*  submitPage URL of the page that will receive the data
   *  This page will send back to the resultPage a message in
   *  the message variable.
   */
  var $submitPage = "mdfproceed.php3";
  var $resultPage = "" ;       /* URL of the page that will display the message result. */
  
  var $readonly ;   /* List of the field to be diplayed, its overhide the readonly in the registry */
  var $labelfield ;    /* List of the label to overhide table field names */
  var $picture ;
  var $listfield ;
  var $hidefield ;
  var $required;
  var $default;
  var $optiontype ;
  var $emailfield;
  var $access ;
  var $datef ;

  var $requiredPage = "requiredfield.html";
  var $requiredIndicator = "*" ;
  var $requiredLegend = "(*) sont obligatoires";
  var $secondary_key ;   /* For linktable to add the secondary key to the form */

  /* Information for the table presentation of the form */
   var $tblBorder = "0" ;       /* Lenght of the table border */
   var $tblWidth = "100%" ;
   var $tblCellspacing ="0" ;
   var $tblCellpadding = "0" ;

  /* Code uniquement pour formfusion a supprimer */
   var $tblEditForm = false;
   var $tblLabelEdit;
   var $tblLabelDelete;
   var $frmFormId = "" ;

   var $frmTextareaCols = "40" ;    /* Number of cols for the textarea */
   var $frmTextareaRows = "5" ;      /* Number of rows for the textarea */
   var $frmFieldSize = "40" ;    /* Size of the fields in char */
   var $frmSubmitButton = "Valider" ;  /* The submit button */
   var $frmTypeSubmit ;


  /*     Fonction printform()
     Generate a form in a table based on the table structure.
     It use the informations of the registry table to include special informations
     For the presentation of the table you can use CSS style.
     Class name for the label col is : adformlabel
     Class name for the field col is : adformfield
     Class name for the table is : adformtable

  */

function printform($dbc, $wherequery) {

  $iddbc = $dbc->start();
  $thereisapicture = false ;
	  
  /* Getting information from the registry for the date */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='datef'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->datef[$rfield] == "")  {
        $this->datef[$rfield]=$rdata ;
      }
    }
  }
	  
	  
  /* Getting information from the registry for the access (login and password) */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='access'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->access[$rfield] == "")  {
        $this->access[$rfield]=$rdata ;
      }
    }
  }

  /* Getting information from the registry for the pictures uploads */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='picture'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->picture[$rfield] == "")  {
        $this->picture[$rfield]=$rdata ;
		$thereisapicture = true ; 
      }
    }
  }
  /* Getting information from the registry for the readonly fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='readonly'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->readonly[$rfield] == "") {
        $this->readonly[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the list fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='list'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ( $this->listfield[$rfield] == "") {
        $this->listfield[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the hidden fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='hidden'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->hidefield[$rfield]=="") {
        $this->hidefield[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the labels */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='label'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->labelfield[$rfield] == "") {
        $this->labelfield[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the required */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='required'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->required[$rfield] == "") {
        $this->required[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the emal fields*/
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='email'",  $iddbc) ;
    if ($rregistry >0) {
      while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
        if ($this->emailfield[$rfield] == "") {
          $this->emailfield[$rfield]=$rdata ;
      }
    }
  }

  /* Getting information from the registry for the default value */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='default'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->default[$rfield] == "") {
        $this->default[$rfield]=$rdata ;
      }
    }
  }

  /* Getting information from the registry for the optiontype */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='optiontype'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->optiontype[$rfield] == "") {
        $this->optiontype[$rfield]=$rdata ;
      }
    }
  }

  $table_def = mysql_db_query($dbc->db, "SHOW FIELDS FROM $dbc->table", $iddbc);
  if(strlen($this->secondary_key)>0) {
    $this->secondary_key = stripslashes($this->secondary_key) ;
    list($primary_name, $primary_value) = explode ("=", $this->secondary_key) ;
    $primary_value = ereg_replace ("^'", "", $primary_value) ;
    $primary_value = ereg_replace ("'$", "", $primary_value) ;
  }
  if ((strlen($wherequery)>1)) {
    $wherequery = stripslashes($wherequery) ;
    $result = mysql_db_query($dbc->db, "SELECT * FROM $dbc->table WHERE $wherequery", $iddbc);
    if ($result>0) {
    $row = mysql_fetch_array($result);
      $newrecord = 0;
    }
  } else {
    $result = mysql_db_query($dbc->db, "SELECT * FROM $dbc->table LIMIT 1", $iddbc);
    $newrecord = 1 ;
  }
  if (!$table_def) {
    echo "Error Mysql die";
  } else {
  /* Test if there is pictures or file in this form */
  // echo "nbrphoto:".count($this->picture) ; 
  if ($thereisapicture)  { ?>
<form method="post" ENCTYPE="multipart/form-data" action="<?php echo $this->submitPage; ?>">
<input type="hidden" NAME="MAX_FILE_SIZE" VALUE = "1000000">
<?php
  } else {
?>
<form method="post" action="<?php echo $this->submitPage; ?>">
<?php 
  } 
  if (strlen($this->frmFormId)>0) : ?>
<input type="hidden" name="theform" value="<?php echo $this->frmFormId;?>">
<?php 
  else: ?>
<input type="hidden" name="table" value="<?php echo $dbc->table;?>">
<input type="hidden" name="goto" value="<?php echo ($this->resultPage); ?>">
<input type="hidden" name="requiredURL" value="<?php echo ($this->requiredPage); ?>">
<?php 
  endif; 
  if (strlen($wherequery)>1) {
    echo '<input type="hidden" name="primary_key" value="'.$wherequery.'">';
  }
?>
<table width="<?php echo $this->tblWidth; ?>" border="<?php echo $this->tblBorder;?>" cellspacing="<?php  echo $this->tblCellspacing; ?>" cellpadding="<?php echo $this->tblCellpadding; ?>" class="adformtable">
<?php
  for ($i=0;$i<mysql_num_rows($table_def);$i++) {
    $row_table_def = mysql_fetch_array($table_def);
    $field = $row_table_def["Field"];
    if (($row_table_def['Type']  == "datetime") AND ($row[$field] == "")) {
      $row[$field] = date("Y-m-d H:i:s", time());
    }
    $len = @mysql_field_len($result,$i);
    echo "<tr>\n";
    echo "<td  align=right><div class=adformlabel>";
    if($this->required[$field]) {
      echo '<INPUT name="required['.$field.']" type="hidden" value="yes">';
      $requiredStar = $this->requiredIndicator;
    }
    if($this->emailfield[$field]) {
      echo '<INPUT name="emailfield[]" type="hidden" value="'.$field.'">';
    }
    if($this->access[$field]) {
      echo '<INPUT name="accessfield['.$this->access[$field].']" type="hidden" value="'.$field.'">';
    }  
    if (!$this->hidefield[$field] && !$this->readonly[$field]) {
      if(strlen($this->labelfield[$field])>0) {
        echo $this->labelfield[$field]." &nbsp;&nbsp;$requiredStar&nbsp;";
      } else {
        echo $field." &nbsp;&nbsp;$requiredStar&nbsp;"; 
      }
    }
    echo "</div></td>\n";
	$requiredStar = "";
    if (isset($row) && isset($row[$field])) {
      $special_chars = htmlspecialchars($row[$field]);   // Value for HTML presentation
    } else $special_chars = "";
    if ($field == $primary_name) {
    /*      echo "Clé secondaire : ".$field ; */
      if (!(strlen($row[$field])>0)) { $row[$field] = $primary_value;}
    }
    if (isset($this->default[$field]) && $newrecord) {
      $row[$field] = $this->default[$field];
    }
    if ($this->readonly[$field]) {
      echo "<td><div class=adformfield>";
      echo "<input type=hidden name=fields[$field] value=\"".$row[$field]."\" maxlength=$len><div></td>"  ;
    } elseif($this->hidefield[$field]) {
      echo "<td><input type=hidden name=fields[$field] value=\"".$row[$field]."\" maxlength=$len></td>"  ;
    } elseif($this->access[$field]=="password") {
      echo "<td><input type=password name=fields[$field] value=\"".$row[$field]."\" maxlength=$len>" ;
	  echo "\n<br><input type=password name=fieldrepeatpass[$field] value=\"".$row[$field]."\" maxlength=$len> </td>"  ;
    } elseif (strstr($row_table_def["Type"], "text")) {
      echo "<td><div class=adformfield><textarea name=fields[$field] rows=$this->frmTextareaRows cols=$this->frmTextareaCols>$special_chars</textarea></div></td>\n";
    } elseif ($this->optiontype[$field] == "checkbox") {
      echo "<td><input type=hidden name=fields[$field] value=\"\">" ;
      if (strlen($row[$field])>0) { $checkboxvalue = $row[$field]; } else { $checkboxvalue = $this->default[$field]; }
        echo "\n<div class=adformfield><INPUT name=fields[$field] value=\"".$checkboxvalue."\" type=\"checkbox\"";
        if ((strlen($row[$field])>0) && !($newrecord)) { echo " checked"; }
        echo "></div></td>";
        $checkboxvalue = "";
    } elseif (strstr($row_table_def["Type"], "enum") && $this->optiontype[$field]=="listbox") {
      $set = ereg_replace("''", "~", $row_table_def["Type"]);
      $set = ereg_replace("set\(|enum\(|'|\)", "", $set);
      $set = ereg_replace("~", "'", $set);
      $set = explode(",", $set);
      echo "<td><div class=adformfield><select name=fields[$field]>\n";
      for ($j=0; $j<count($set);$j++) {
        echo "<option value=\"$set[$j]\"";
        if ($special_chars == $set[$j])  echo " selected";
        echo ">$set[$j]";
      }
      echo "</select></div></td>";
      //  $optiontype = "&optiontype=listbox";
      } elseif (strstr($row_table_def["Type"], "enum") && $this->optiontype[$field]=="radiobutton") {
        $set = ereg_replace("''", "~", $row_table_def["Type"]);
        $set = ereg_replace("set\(|enum\(|'|\)", "", $set);
        $set = ereg_replace("~", "'", $set);
        $set = explode(",", $set);
        echo "<td><div class=adformfield>\n";
        for ($j=0; $j<count($set);$j++) {
          echo "<INPUT name=fields[$field] value=\"$set[$j]\" type=\"radio\"" ;
          if ($special_chars == $set[$j]) echo " checked";
          echo ">$set[$j]<BR>";
        }
        echo "</div></td>";
        //  $optiontype = "&optiontype=listbox";
      } elseif ($this->picture[$field] <> "") {   
      // $picturedisplay = "exists" ;
      /* Display file field to upload the file  */
      echo "<td><div class=adformfield>" ; ?>
      <input type="hidden" name="filefield[]" value="<?php echo $field; ?>">
      <input type=hidden name=fields[<? echo $field; ?>] value="<? echo $row[$field]; ?>">
      <!---- <input name=filechange[<? echo $field; ?>] type=checkbox value="yes">
	  --->
	  <input name="userfile[]" type="file">
<?    if($row[$field]!="") echo "(".$row[$field].")"; echo "</div></td>" ;
 /*        echo "<td><div class=adformfield><input type=hidden name=fields[$field] value=\"".$row[$field]."\" maxlength=$len>";
            echo "$special_chars</div></td>";
    */
      } elseif ($this->listfield[$field] <> "") {
        list($tablename, $fielduniqid, $fielddisplay, $defaultvalue) = explode (":", $this->listfield[$field]) ;
        if (strlen($row[$field]) > 0) { $defaultvalue = $row[$field];  }
        echo "<td><div class=adformfield><select name=fields[$field]>\n" ;
        $rlist = mysql_db_query($dbc->db, "select $fielddisplay, $fielduniqid from $tablename order by $fielddisplay") ;
        while (list($vfielddisplay, $vfielduniqid) = mysql_fetch_row($rlist)) {
          $tmp_selected = "" ;
          if ($vfielduniqid == $defaultvalue) { $tmp_selected = " selected" ; }
          echo "<option value=".$vfielduniqid.$tmp_selected.">".$vfielddisplay."</option>\n" ;
        }
        echo "</select></div></td>";
      } elseif ($this->datef[$field] <> "") {
		$day = date("d", $row[$field]) ; $month = date("m", $row[$field]) ; $year = date("Y", $row[$field]) ; 
        echo "<td><div class=adformfield> <input type=hidden name=datefieldname[] value=\"".$field."\">"; 
        $fday = " <input type=text name=datefieldday[$field] value=\"".$day."\"  size=4  maxlength=4>" ;
	    $fmonth = " <input type=text name=datefieldmonth[$field] value=\"".$month."\"  size=4  maxlength=4>" ;	
	    $fyear = " <input type=text name=datefieldyear[$field] value=\"".$year."\"  size=4  maxlength=4>" ;
		$datefields = str_replace("d", "philippeisjour", $this->datef[$field]) ;
	    $datefields = str_replace("m", "philippeismois", $datefields) ;
		$datefields = str_replace("Y", "philippeisanne", $datefields) ;
	    $datefields = str_replace("philippeisjour", $fday, $datefields) ;
		$datefields = ereg_replace("philippeismois", $fmonth, $datefields) ;
		$datefields = ereg_replace("philippeisanne", $fyear, $datefields) ;
		echo $datefields ;
		echo "</div></td>"; 
	  } else {
        echo "<td><div class=adformfield> <input type=text name=fields[$field] value=\"$row[$field]\"  size=$this->frmFieldSize  maxlength=$len></div></td>";
      }
/* This is temporairy code only for MyDB IDE */
      if ($this->tblEditForm == true) {
        echo "<td>[<a href=\"ffeditfield.php?fieldname=".$field.$optiontype."\">".$this->tblLabelEdit."</a>]</td>";
        echo "<td>[<a href=\"ffdeletefield.php?fieldname=".$field."\">".$this->tblLabelDelete."</a>]</td>" ;
      }
      echo "</tr>\n";
    }
    echo "</table>";
  } 
?> <p><?php
  echo $this->requiredLegend; ?></p>
<?php 
  if ($this->frmTypeSubmit) {
    echo $this->frmTypeSubmit; 
  } else {?>
    <P align="center">
    <input type="submit" value="<?php echo $this->frmSubmitButton; ?>">
    </p>
  <?php
  } 
?>
  </form>
<?php
}


/* Show the record */


function showrecord($dbc, $wherequery) {
global $PHP_SELF;
  $filenameselfarray = explode("/", $PHP_SELF);
  $filenameself = $filenameselfarray[count($filenameselfarray)-1];
  $iddbc = $dbc->start();

  /* Getting information from the registry for the pictures uploads */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='picture'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->picture[$rfield] == "")  {
        $this->picture[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the readonly fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='readonly'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->readonly[$rfield] == "") {
        $this->readonly[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the list fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='list'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ( $this->listfield[$rfield] == "") {
        $this->listfield[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the hidden fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='hidden'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->hidefield[$rfield]=="") {
        $this->hidefield[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the labels */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='label'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->labelfield[$rfield] == "") {
        $this->labelfield[$rfield]=$rdata ;
      }
    }
  }

  /* Getting information from the registry for the emal fields*/
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='email'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->emailfield[$rfield] == "") {
        $this->emailfield[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the optiontype */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from registry where rtable='$dbc->table' and rtype='optiontype'",  $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if ($this->optiontype[$rfield] == "") {
        $this->optiontype[$rfield]=$rdata ;
      }
    }
  }
  $table_def = mysql_db_query($dbc->db, "SHOW FIELDS FROM $dbc->table", $iddbc);
    if(strlen($this->secondary_key)>0) {
      $this->secondary_key = stripslashes($this->secondary_key) ;
      list($primary_name, $primary_value) = explode ("=", $this->secondary_key) ;
      $primary_value = ereg_replace ("^'", "", $primary_value) ;
      $primary_value = ereg_replace ("'$", "", $primary_value) ;
    }
    if ((strlen($wherequery)>1)) {
      $wherequery = stripslashes($wherequery) ;
      $result = mysql_db_query($dbc->db, "SELECT * FROM $dbc->table WHERE $wherequery", $iddbc);
      if ($result>0) {
        $row = mysql_fetch_array($result);
    //    echo "récupération donnée OK ";
        $newrecord = 0;
      }
    } else {
      $result = mysql_db_query($dbc->db, "SELECT * FROM $dbc->table LIMIT 1", $iddbc);
      $newrecord = 1 ;
    }
    if (!$table_def) {
      echo "Error Mysql die";
    } else {
?>
<table width="<?php echo $this->tblWidth; ?>" border="<?php echo $this->tblBorder;?>" cellspacing="<?php  echo $this->tblCellspacing; ?>" cellpadding="<?php echo $this->tblCellpadding; ?>" class="adshowrectable">
<?php
      for ($i=0;$i<mysql_num_rows($table_def);$i++) {
        $row_table_def = mysql_fetch_array($table_def);
        $field = $row_table_def["Field"];
        if (($row_table_def['Type']  == "datetime") AND ($row[$field] == "")) {
          $row[$field] = date("Y-m-d H:i:s", time());
        }
        $len = @mysql_field_len($result,$i);
        echo "<tr>\n";
        echo "<TD align=right valign=top><div class=adshowreclabel>";

        if (!$this->hidefield[$field] && !$this->readonly[$field]) {
          if(strlen($this->labelfield[$field])>0) {
            echo $this->labelfield[$field];
          } else {
            echo $field; 
	      }
        }
        echo "</div></td>\n";
        $requiredStar = "";
        if (isset($row) && isset($row[$field])) {
           $special_chars = htmlspecialchars($row[$field]);   // Value for HTML presentation
        } else $special_chars = "";
 
        if ($field == $primary_name) {
        /*      echo "Clé secondaire : ".$field ; */
          if (!(strlen($row[$field])>0)) { $row[$field] = $primary_value;}
        }
        if (isset($this->default[$field]) && $newrecord) {
          $row[$field] = $this->default[$field];
        } elseif($this->hidefield[$field]) {
               /* Do nothing just wait. */
        } elseif (strstr($row_table_def["Type"], "text")) {
          echo "<td><div class=adshowrecfield>".nl2br($special_chars)."</div></td>\n";
        } elseif ($this->picture[$field] <> "") {
          list($picturedisp,$picturerealurl) = explode(":", $row[$fields]);
          echo "<td><div class=adshowrecfield>&nbsp;<a href=\"ffdownload.php3?filename=".rawurlencode($picturedisp)."&filelocation=".rawurlencode($picturerealurl)."\">".$picturedisp."</a>";
          echo "</div></td>";
        } elseif ($this->listfield[$field] <> "") {
          list($tablename, $fielduniqid, $fielddisplay, $defaultvalue) = explode (":", $this->listfield[$field]) ;
          if (strlen($row[$field]) > 0) { $defaultvalue = $row[$field];  }
          echo "<td><div class=adshowrecfield>" ;
          $rlist = mysql_db_query($dbc->db, "select $fielddisplay, $fielduniqid from $tablename ") ;
            while (list($vfielddisplay, $vfielduniqid) = mysql_fetch_row($rlist)) {
              $tmp_selected = "" ;
              if ($vfielduniqid == $defaultvalue) { $tmp_selected = " selected" ; }
              echo $vfielddisplay ;
            }
          echo "</div></td>";
        } else   {
          echo "<td><div class=adshowrecfield>".$special_chars."</div></td>";
        }
        echo "</tr>\n";
      }
      echo "</table>";
      echo "<table><tr>";
      $primary_key = ereg_replace("^ ", "", $primary_key) ;
      $primary_key = urlencode(ereg_replace(" AND$", "", $primary_key));
      //             $query = "db=$dbc->db&table=$dbc->table&goto=".urlencode($filenameself);
      $query = "db=$dbc->db&table=$dbc->table&goto=".urlencode($GLOBALS[REQUEST_URI]);
        if ($this->cfgEditRecord) {
          if (strlen($this->cfgEditResultPage) >0) {
            $query = "db=$dbc->db&table=$dbc->table&goto=".urlencode($this->cfgEditResultPage) ;
          }
          echo "<td><a href=\"$this->cfgEditPage?$query&wherequery=".urlencode($wherequery)."\">".$this->strEdit."</a></td>";
        }
        if ($this->cfgDeleteRecord) {
          if (strlen($this->cfgDelResultPage) >0) {
            $query = "db=$dbc->db&table=$dbc->table&goto=".urlencode($this->cfgDelResultPage);
          }
          $deleteparams = "&strYes=".urlencode("$this->strYes")."&strNo=".urlencode("$this->strNo")."&strDoYouReallyDelete=".urlencode("$this->strDoYouReallyDelete")."&cfgConfirmDelete=".$this->cfgConfirmDelete;
            echo "<td><a href=\"$this->cfgDeletePage?$query&sql_querywhere=".urlencode("WHERE ".$wherequery).$deleteparams."\">".$this->strDelete."</a></td>";
          }
        echo "</tr></table>";
      }
    }
  }
   /*
    *  Class mydataTable
    *  Génerate table
    *
    *
    *
   */

Class mydataTable {
 /* Parameters dynamique in run times
     to work correctly they must be overhide.
     Dont just use de default */

   var $pos ;
   var $sql_query;
   var $sql_order ;

 /* Parameters for the tables functions */

   var $cfgBorder = "0";       /* Border of the Table */
   var $cfgBgcolorOne = "#CCCCCC";   /* Background color of the line 1 */
   var $cfgBgcolorTwo = "#DDDDDD";    /* Background color of the line 2 */
   var $cfgMaxRows = 10;    /* Maximum numbers of rows per page */
   var $cfgOrder = "ASC"   ;   /* Default orders of the query's */
   var $cfgShowBlob = true ;   /*  Show the content of blob fields (false to hide) */
   var $cfgWarpcels = 0 ;                 /* Limite la longueur des cellules à une valeur fixe. */
   var $cfgHtmlEntities = true;  /* Convertie la chaine a afficher en htmlentites */

/* Variable de la registry */
    var $showlist;          /* Récupere une valeur dans une autre table. */
    var $showpicture;          /* Display pictures. */
    var $labelfield ;       /* Label correspondant au nom des colonnes */
    var $hidefield ;       /* To Hide a col must contain the value 1 */
	var $datef ;			/* Date Format */

/* Activate the options when display the table */

   var $cfgOrderTable = true ;   /* true= show link in the field name to order the table */

   var $cfgEditRecord = true ;    /* Show link to edit the record */
   var $cfgDeleteRecord = true ;    /* Show link to delete the record */
   var $cfgLinkTableRecord = true;   /* Show link to the linked table of the record */
   var $cfgAddRecord = true ;    /* Show link to add a record in the table */

   var $cfgConfirmDelete = "Yes" ;   /*Show a dialog box to confirm delete use "No" for direct delete */

/* URL of the page linked for edit, add, linktable and delete */

   var $cfgEditPage = "mydataedit.php3";    /* URL of the page that edit the record */
   var $cfgAddPage = "mydataedit.php3";   /* URL of the page that Add a record */
   var $cfgDeletePage = "mydatadelete.php3";   /* URL of the page that delete a record */
   var $cfgLinkTablePage = "mydatalinktable.php3";   /* URL of the page show the linked tables of the record */

 /* Texte used in this class : english  */
   var $strShowingRecords   = "Showing records ";
   var $strNoRecords = "There is no records";
   var $strTotal      = "total";
   var $strEdit      = "Edit";
   var $strPrevious   = "Previous";
   var $strNext      = "Next";
   var $strDelete      = "Delete";
   var $strDeleted      = "The row has been deleted";
   var $strLinkedTable    = "Linked Table";
   var $strPos1                   = "Begin";
   var $strEnd                    = "End";
   var $strInsertNewRow   = "Insert new row";
   var $strYes      = "Yes";
   var $strNo      = "No";
   var $strDoYouReallyDelete = "Do you really want to delete this record";


 /* Texte used in this class : French
   var $strNoRecords = "Il n'y a aucun enregistrement";
    var $strShowingRecords   = "Affichage des enregistrements";
    var $strTotal      = "total";
    var $strEdit      = "Modifier";
    var $strPrevious   = "Précédent";
    var $strNext      = "Suivant";
   var $strDelete      = "Effacer";
   var $strDeleted      = "L'enregistrement a été effacé";
   var $strLinkedTable    = "Tables Liés";
   var $strPos1                   = "Début";
   var $strEnd                    = "Fin";
   var $strInsertNewRow   = "Insérer un nouvel enregistrement";
   var $strYes      = "Oui";
   var $strNo      = "Non";
   var $strDoYouReallyDelete = "Voulez vous vraiment supprimer l'enregistrement ";
*/

 /*     Fonction query()
   Execut a query on the database
   recieved in parameters a mysqlconnect object and return a
   mysql query result.
   Use this function beford display table.
  *

function query($dbc) {
  $this->sql_query = stripslashes($this->sql_query);
  $this->sql_order = stripslashes($this->sql_order);
  if ($this->sql_query == "") {
    $this->sql_query= "select * from $dbc->table" ;
  }
  $rquery = mysql_db_query($dbc->db,$this->sql_query.$this->sql_order, $dbc->start());
  return $rquery ;
}
*/
 /*     Fonction displaytable()
   It displays a table with a record management. (Add, edit, delete, linktable)
    For the presentation of the table you can use CSS style.
     Class name for the label col is : adformlabel
     Class name for the field col is : adformfield
     Class name for the table is : adformtable
  */
  
function displaytable ($dbc, $dt_result) {
  global $PHP_SELF,$REQUEST_URI;
  $primary = false;
  $iddbc = $dbc->start();
  $filenameselfarray = explode("/", $PHP_SELF);
  $filenameself = $filenameselfarray[count($filenameselfarray)-1];

  /* Getting information from the registry for the pictures uploads */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from $dbc->registryTable where rtable='$dbc->table' and rtype='picture'", $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      $picture[$rfield]=$rdata ;
    }
  }

  /* Getting information from the registry to display the date */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from $dbc->registryTable where rtable='$dbc->table' and rtype='datef'", $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if (!strlen($this->datef[$rfield])>0) {
        $this->datef[$rfield]=$rdata ;
      }
    }
  }

  /* Getting information from the registry to display the pictures */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from $dbc->registryTable where rtable='$dbc->table' and rtype='showpicture'", $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if (!strlen($this->showpicture[$rfield])>0) {
        $this->showpicture[$rfield]=$rdata ;
      }
    }
  }

  /* Getting information from the registry for the list fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from $dbc->registryTable where rtable='$dbc->table' and rtype='list'", $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if (!strlen($this->showlist[$rfield])>0) {
        $this->showlist[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the hidden fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from $dbc->registryTable where rtable='$dbc->table' and rtype='hidden'", $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if (!(strlen($this->hidefield[$rfield])>0)) {
        $this->hidefield[$rfield]=$rdata ;
      }
    }
  }
  /* Getting information from the registry for the email fields */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from $dbc->registryTable where rtable='$dbc->table' and rtype='email'", $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
	  if (!strlen($this->labelfield[$rfield])>0) {
        $emailfield[$rfield]=$rdata ;
      }
	}
  }

  /* Getting information from the registry for the labels */
  $rregistry= mysql_db_query($dbc->db, "select rfield, rdata from $dbc->registryTable where rtable='$dbc->table' and rtype='label'", $iddbc) ;
  if ($rregistry >0) {
    while (list($rfield, $rdata) = mysql_fetch_row($rregistry)) {
      if (!strlen($this->labelfield[$rfield])>0) {
        $this->labelfield[$rfield]=$rdata ;
      }
    }
  }


  if (!isset($dbc->pos))    $dbc->pos = 0;

  $pos_next = $dbc->pos + $dbc->max_rows;
  $pos_prev = $dbc->pos - $dbc->max_rows;
  $this->cfgMaxRows = $dbc->max_rows ;


  if ($dbc->num_rows >$dbc->max_rows) {
    echo "$this->strShowingRecords $dbc->pos - $pos_next (".$dbc->num_rows." $this->strTotal )";
  } else { echo $this->strShowingRecords." 0-".$dbc->num_rows;    }
?>
 <table border="<?php echo $this->cfgBorder;?>">
  <tr>
<?php
  while ($field = mysql_fetch_field($dt_result)) {
    if(!$this->hidefield[$field->name]) {
      if (strlen($this->labelfield[$field->name])>0) {
        $tmp_labelfield = $this->labelfield[$field->name] ;
      } else {
        $tmp_labelfield = $field->name ;
      }
      if (@mysql_num_rows($dt_result)>0) {
        $sort_order=urlencode(" order by '$field->name' $this->cfgOrder");
        if ($this->cfgOrderTable) {
          echo "<th><A HREF=\"$filenameself?server=$dbc->server&db=$dbc->db&pos=$dbc->pos&sql_query=".urlencode($dbc->sql_query)."&sql_order=$sort_order&table=$table\">$tmp_labelfield</a></th>\n";
        } else { echo "<th>$tmp_labelfield</th>"; } ;
      } else {
        echo "<th>&nbsp;</th>";
        $norecord = 1;
      }
    }
    $table = $field->table;
  } 
  echo "</tr>\n";
  if ($norecord) { echo $this->strNoRecords; }
  $foo = 0;
  while ($row = mysql_fetch_row($dt_result)) {
    $primary_key = "";
    $bgcolor = $this->cfgBgcolorOne;
    $foo % 2  ? 0: $bgcolor = $this->cfgBgcolorTwo;
    echo "<tr bgcolor=$bgcolor>";
    $foo++;
    for ($i=0; $i<mysql_num_fields($dt_result); $i++) {
      if (!isset($row[$i])) $row[$i] = '';
        $primary = mysql_fetch_field($dt_result,$i);
        $affvalue = $row[$i] ;
      if ($this->cfgWarpcels>0) {
        $affvalue = substr($affvalue, 0, $this->cfgWarpcels) ;
        $affvalue = ereg_replace(" ", "&nbsp;", $affvalue) ;
      }
      if ($this->cfgHtmlEntities) {
        $affvalue = htmlentities($affvalue) ;
      }
	  
      if($this->hidefield[$primary->name]) {
        /* do nothing, just wait and see */
      } elseif($picture[$primary->name]) {
        if($this->showpicture[$primary->name] == 1) {                   
          if($row[$i]=="") { 
            echo "<td align=right>&nbsp;</td>\n";
          } else {
            list($picturerealurl,$regname, $regcontentype) = explode(":", $picture[$primary->name]);
            $picturefullpathname=$picturerealurl."/".$row[$i];
            echo "<td align=right><IMG src=\"$picturefullpathname\" alt=\"$row[$i]\"></td>\n";
          }
        } else {
          list($picturerealurl,$regname, $regcontentype) = explode(":", $picture[$primary->name]);
          $picturefullpathname=$picturerealurl."/".$row[$i];
          echo "<td>&nbsp;<a href=\"".$picturefullpathname."\">".$row[$i]."</a></td>\n";   
        }
      } elseif($emailfield[$primary->name] == 1) {
        echo "<td><a href=\"mailto:$row[$i]\">$row[$i]</a>&nbsp;</td>\n";
      } elseif(strlen($this->datef[$primary->name]) > 0) {
        echo "<td>".date($this->datef[$primary->name],$row[$i])."&nbsp;</td>\n";
      } elseif(isset($this->showlist[$primary->name])) {
        list($tablename, $fielduniqid, $fielddisplay, $defaultvalue) = explode (":", $this->showlist[$primary->name]) ;
        $query_list = "select $fielddisplay, $fielduniqid from $tablename where $fielduniqid='$row[$i]'" ;
        $rlist = mysql_db_query($dbc->db, $query_list) ;
        list($vfielddisplay, $vfielduniqid) = mysql_fetch_row($rlist) ;
        if ($this->cfgWrapcels>0) {
          $vfielddisplay = substr($vfielddisplay, 0, $this->cfgWrapcels) ;
          $vfielddisplay = ereg_replace(" ", "&nbsp;", $vfielddisplay) ;
        }
        echo "<td>&nbsp; $vfielddisplay &nbsp;</td>";
      } elseif ($primary->numeric == 1) {
        echo "<td align=right>&nbsp;$affvalue&nbsp;</td>\n";
      } elseif ($this->cfgShowBlob == false && eregi("BLOB", $primary->type)) {
        echo "<td align=right>&nbsp;[BLOB]&nbsp;</td>\n";
      } else {
        echo "<td>&nbsp;".$affvalue."&nbsp;</td>\n";
      }
      if ($primary->primary_key > 0)
        $primary_key .= " $primary->name='$row[$i]' AND";
      }
      if ($primary_key) {
        $primary_key = ereg_replace("^ ", "", $primary_key) ;
        $primary_key = urlencode(ereg_replace(" AND$", "", $primary_key));
        $query = "db=$dbc->db&table=$table&goto=".urlencode($REQUEST_URI);
        if ($this->cfgEditRecord) {
          echo "<td><a href=\"$this->cfgEditPage?$query&wherequery=$primary_key\">".$this->strEdit."</a></td>";
        }
        if ($this->cfgDeleteRecord) {
          $deleteparams = "&strYes=".urlencode("$this->strYes")."&strNo=".urlencode("$this->strNo")."&strDoYouReallyDelete=".urlencode("$this->strDoYouReallyDelete")."&cfgConfirmDelete=".$this->cfgConfirmDelete;
          echo "<td><a href=\"$this->cfgDeletePage?$query&sql_querywhere=".urlencode("WHERE ").$primary_key.$deleteparams."\">".$this->strDelete."</a></td>";
        }
        if ($this->cfgLinkTableRecord) {
          echo "<td><A href=\"$this->cfgLinkTablePage?db=".$dbc->db."&table=".$table."&wherequery=".$primary_key."&strInsertNewRow=".urlencode($this->strInsertNewRow)."&cfgAddPage=".urlencode($this->cfgAddPage)."\">";
          echo $this->strLinkedTable;
          echo "</A></td>";
        }
      }
      echo "</tr>\n";
    }
    echo "</table>\n";
    echo "<table border=0 width=60%>";
    if ($dbc->pos >= $dbc->max_rows && $dbc->max_rows>0) {
      echo "<td align=center><a href=\"$filenameself?db=$dbc->db&table=$table&sql_query=".urlencode($dbc->sql_query)."&sql_order=".urlencode($dbc->sql_order)."&pos=0\">&lt;&lt; $this->strPos1 </a>";
      echo "<a href=\"$filenameself?db=$dbc->db&table=$table&sql_query=".urlencode($dbc->sql_query)."&sql_order=".urlencode($dbc->sql_order)."&pos=$pos_prev\">&lt; $this->strPrevious </a></td>";
    }
    if (mysql_num_rows($dt_result) == $dbc->max_rows) {
      echo "<td align=center><a href=\"$filenameself?db=$dbc->db&table=$table&sql_query=".urlencode($dbc->sql_query)."&sql_order=".urlencode($dbc->sql_order)."&pos=$pos_next\"> $this->strNext &gt;</a>";
    if ($dbc->num_rows) {
      printf ("<a href=\"$filenameself?db=$db&table=$table&sql_query=%s&sql_order=%s&pos=%d\"> $this->strEnd &gt;&gt; </a></td>",urlencode($dbc->sql_query),urlencode($dbc->sql_order),floor($dbc->num_rows/$dbc->max_rows)*$dbc->max_rows);
    }
  }
  echo "</table>\n";
  if ($this->cfgAddRecord) {
    echo "<DIV align=\"right\"><a href=\"$this->cfgAddPage?db=$dbc->db&table=$table&goto=".urlencode($GLOBALS[REQUEST_URI])."\"> $this->strInsertNewRow</a></DIV>";
  }

 }

}



?>
Return current item: MyDB