Fetching data from a database and displaying it in a table format
This is a simple recipe where we will get some data from a table and we'll display it in a page. Users will be presented with a select box with options to choose a programming language. Selecting a language will get some functions and their details from the database.
Getting ready
Create a new folder named Recipe1
inside the Chapter8
directory. Now, using phpMyAdmin create a table named language
in the exampleDB
database using the following query.
CREATE TABLE `language` ( `id` int(3) NOT NULL auto_increment, `languageName` varchar(50) NOT NULL, PRIMARY KEY (`id`) );
Insert two records for languageName
in this table, namely PHP and jQuery. Now, create another table functions
that will have function names and details related to a language.
CREATE TABLE `functions` ( `id` int(3) NOT NULL auto_increment, `languageId` int(11) NOT NULL, `functionName` varchar(64) NOT NULL, `summary` varchar(128) NOT NULL, `example...