PHP Classes

CMySqldbHTML: Display and edit MySQL table records in a Web page

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 146 All time: 9,114 This week: 107Up
Version License PHP version Categories
cmysqldbhtml 1.0The PHP License5HTML, PHP 5, Databases
Description 

Author

This class can display and edit MySQL table records in a Web page.

It can connect to a given MySQL database and retrieves data from that table to display it on a Web page.

The class can also display a form to allow the user to enter data to insert in new records of the given MySQL table.

In Spanish:

CMySqldbHTML esta diseñado para la interacción con bases de datos mysql phpmyadmin y generar HTML a partir de los datos.
CMySqldbHTML is designed for the interaction between data bases mysql phpmyadmin and and create HTML code with the data.
El constructor requiere los parametros - The constructor parameters are:
* $tablenm = Nombre de la tabla - Name of the table
* $db = Nombre de la base de datos - Name of data base
* $host = Nombre o direccion del host o servidor - Name or adress of the host or server
* $user = Nombre de usuario para conexion con la base de datos - User name to connect with the database
* $pass = Conrtaseña para conexion con la base de datos - User password to connect with the database
*
* Hay dos formas de usar la clase - There are two ways for the use of the class:
*
* 1.- $tablenm = "": Si entregamos el nombre de la tabla vacio - If set the table name empty
* $data : Almacena los nombres de las bases de datos - Save the names of the databases
* $tblsdb : Almacena los nombres de las tablas de la base de datos entregada
- Save the names of the tables in the database gived
*
* 2.- $tablenm <> "": Entregando el nombre de una tabla existente - Setting the table name created.
* $numfilas : Numero de filas de la tabla - Numbers of rows in the table
* $numcols : Numero de columnas de la tabla - Numbers of columns in the table
* $hddata : Encabezados de la tabla - Table headers
* $tpar : Tipos de campos de la tabla - Types of table fields
* $lenar : Longitud máxima para los campos de la tabla - Maximum length for the table's fields
* $bandar : Banderas de los campos de la tabla - Flags for the table's fields
* $data : Almacena el contenido de la tabla por filas - Save the rows content of the table
*
* Metodos:
*
* showrCObjeto() :
* 1.- Escribe el codigo HTML para ver la lista de las bases de datos y las tablas de la base de datos asignada
* - Write the HTML code to see the list of databases and tables of the assigned database
* 2.- Escribe el codigo HTML para ver la tabla con sus encabezados
* - Write the HTML code to see the table with its headings
*
* Solo para caso 2 - Only case two(2).
* getrowdata($id,$colid)
* Devuelve un array con los datos del $id, de encontrarlo en la columna o encabezado $colid
* Returns an array with the $id data, if found in the $colid field
*
* drawrowdata($id,$colid)
* Escrible el codigo HTML en una tabla con los datos del $id encontrado en la columna $colid
* Write the HTML code in a table with tha $id data, if found in the $colid field
*
* Para formularios - To forms
* setArcolno($ar)
* $arcolno = $ar, que son los campos que no queremos que dibuje en el formulario,
* como timestamp o autoincremto u otro caso.
*
* drawForm($nm)
* Escribe el codigo HTML de un formulario con los nombres de los campos de la tabla como etiquetas
* remplazando '_' con ' ', para darle presentacion, y poder usar dichos nombres como name en los input
* del formulario para su posterior captura con el metodo _POST.
* El primer input lo hace autococus y crea un tabindex para el form.
* Caracteristicas especiales:
* $arcolno permite que en el formulario no dibuje determinados campos, como timestamp o autoincremto u otro caso.
* $nm es el dato de autorrelleno para el primer campo, en caso de tenerlo lo autorrelena y solo lectura.
* De lo contrario entregamos $nm=''.
*
* Write the HTML code of a form with the names of the fields in the table as labels replacing '_' with ' ', to give
* presentation and be able to use these names as name in the input of the form for later capture with the _POST method.
* The first input is done by autococus and creates a tabindex for the form.
* Special features:
* $arcolno allows the form not to draw certain fields, such as timestamp or autoincremto or another case.
* $nm is the autofill data for the first field, if you have it, the self-fill and read only.
* Otherwise we deliver $nm=''.
*
* getcmpsForm():
* Devuelve un array con los nombres de los encabezados - Return an array with header names
*
* procForm($arrfrm):
* Procesa y graba los datos capturados y recibidos en $arrfrm, usa las variables $tstmp y $ord para identificar y
* autorellenar, ya que normalmente son campos que el formulario no dibuja, y deben estar en $arcolno.
* Para su uso despues de construir el objeto, damos valor a las variables con setTstmp($ts) y setOrd($o).
* It processes and records the data captured and received in $ arrfrm, uses the variables $ tstmp and $ ord to identify
* and autofill, since they are normally fields that the form does not draw, and they must be in $ arcolno.
* For use after building the object, we give value to the variables with setTstmp ($ ts) and setOrd ($ o)
*
* Getters and Setters
* getData() return $this->data;
* getNumfilas() return $this->numfilas;
* getNumcols() return $this->numcols;
* getHddata() return $this->hddata;
* getTblsdb() return $this->tblsdb;
* getTablenm() return $this->tablenm;
* setArcolno($ar) $this->arcolno = $ar;
* getArcolno() return $this->arcolno;
* setTstmp($ts) $this->tstmp = $ts;
* setOrd($o) $this->ord = $o;
*
* @author Luis Gabriel Hernández - alias or nickname: luisga158

Picture of Luis Gabriel Hernandez Valderrama
  Performance   Level  
Name: Luis Gabriel Hernandez ... <contact>
Classes: 2 packages by
Country: Colombia Colombia
Age: 47
All time rank: 367120 in Colombia Colombia
Week rank: 312 Up4 in Colombia Colombia Up
Innovation award
Innovation award
Nominee: 1x

Recommendations

Recommendation for a PHP class to order table by column
Print sorted data from reading html table

Example

<?php
   
/*
    * para ver el ejemplo crear su config.php con los nombres que usa el contructor y cambiar
    * "repovisita" por una tabla de su base de datos
    */
   
include("../config.php");
    include(
"CMySqldbHTML.php");
   
$objnotbl = new CMySqldbHTML("", $database, $server, $db_user, $db_pass);
   
// Cambiar por la tabla propia
   
$tblnm = "repovisita";
   
$obj = new CMySqldbHTML($tblnm, $database, $server, $db_user, $db_pass);
   
// Opcional solo si se quiere usar exepciones
    /*$arexp = array('Marca_temporal','Ord');
    $obj->setArcolno($arexp);
    $obj->setTstmp('Marca_temporal');
    $obj->setOrd('Ord');
    $namesend = 'Luis Gabiel Hern&aacute;ndez Valderrama';
    */
   
$objnotbl->showrCObjeto();
   
$obj->showrCObjeto();
   
$namesend = '';
   
$obj->drawForm($namesend);
?>


  Files folder image Files  
File Role Description
Plain text file CMySqldbHTML.php Class clase
Accessible without login Plain text file enviar.php Example Para procesar formularios con la clase
Accessible without login Plain text file exampleCMSH.php Example Ejemplo uso clase

 Version Control Unique User Downloads Download Rankings  
 0%
Total:146
This week:0
All time:9,114
This week:107Up