Responsive web Framework


Data from database

Read the data contained in a table of the database and display them on the screen


(minimum width: 480px)

Let's say that we want to retrieve the information contained in a table from the database and display it on the screen. This action will be done by a file in php and with the help of predefined objects and functions that we will see later or can be found in the section documentation.

Data recovery

# Connecto to DB
# Read from DB
$db->dbQuery("SELECT name, description FROM ".$db->dbPrefix()."catalog WHERE (id = '".$env->envGet('catalog')."') LIMIT 1 ");
list($str_myname, $str_mydesc) = $db->dbFetch('row');
# Logout form DB
In this case, the object called $ db is a link to the database, whereas the object $ env to the environment values as parameters. The code shown is very simple. In the first line the system connects to the database using a predefined method. The following line executes a query on the database, passing as parameter the value of catalog.
The next line retrieves the value obtained and delivers it as an array, assigning it to two variables. By last; The system is disconnected from the database.

Data format

# muestra los datos, ocultando descripción para pantallas pequeñas.

<?php echo $env->envGet('myid'); ?>
Here, the data is displayed, leaving to CSS the options of hiding and formatting the data.