PHP MySQLi Test - Database 'world'

Table:   Choose database table or Search for a Country.

Server: 8.0.33, Host: 208.87.130.131 via TCP/IP
Key field: Code
Query: "SELECT Code, Name, Continent, Region, SurfaceArea, IndepYear, Population, LifeExpectancy, GNP, GNPOld, LocalName, GovernmentForm, HeadOfState, Capital, Code2 FROM country  ORDER BY Code ASC"
Query returned 239 rows (12 pages @ 20 rows per page).
Showing page 1 of 12. First record listed is #0 (counting from zero).
Query Results - Table 'country'
  
ABWArubaNorth AmericaCaribbean193103,00078.40828793ArubaNonmetropolitan Territory of The NetherlandsBeatrix129AWEdit
AFGAfghanistanAsiaSouthern and Central Asia652,0901,91922,720,00045.905,976Afganistan/AfqanestanIslamic EmirateMohammad Omar1AFEdit
AGOAngolaAfricaCentral Africa1,246,7001,97512,878,00038.306,6487,984AngolaRepublicJosé Eduardo dos Santos56AOEdit
AIAAnguillaNorth AmericaCaribbean968,00076.1063.20AnguillaDependent Territory of the UKElisabeth II62AIEdit
ALBAlbaniaEuropeSouthern Europe28,7481,9123,401,20071.603,2052,500ShqipëriaRepublicRexhep Mejdani34ALEdit
ANDAndorraEuropeSouthern Europe4681,27878,00083.501,630AndorraParliamentary Coprincipality55ADEdit
ANTNetherlands AntillesNorth AmericaCaribbean800217,00074.701,941Nederlandse AntillenNonmetropolitan Territory of The NetherlandsBeatrix33ANEdit
AREUnited Arab EmiratesAsiaMiddle East83,6001,9712,441,00074.1037,96636,846Al-Imarat al-´Arabiya al-MuttahidaEmirate FederationZayid bin Sultan al-Nahayan65AEEdit
ARGArgentinaSouth AmericaSouth America2,780,4001,81637,032,00075.10340,238323,310ArgentinaFederal RepublicFernando de la Rúa69AREdit
ARMArmeniaAsiaMiddle East29,8001,9913,520,00066.401,8131,627HajastanRepublicRobert Kotšarjan126AMEdit
ASMAmerican SamoaOceaniaPolynesia19968,00075.10334Amerika SamoaUS TerritoryGeorge W. Bush54ASEdit
ATAAntarcticaAntarcticaAntarctica13,120,00000–Co-administratedAQEdit
ATFFrench Southern territoriesAntarcticaAntarctica7,78000Terres australes françaisesNonmetropolitan Territory of FranceJacques ChiracTFEdit
ATGAntigua and BarbudaNorth AmericaCaribbean4421,98168,00070.50612584Antigua and BarbudaConstitutional MonarchyElisabeth II63AGEdit
AUSAustraliaOceaniaAustralia and New Zealand7,741,2201,90118,886,00079.80351,182392,911AustraliaConstitutional Monarchy, FederationElisabeth II135AUEdit
AUTAustriaEuropeWestern Europe83,8591,9188,091,80077.70211,860206,025ÖsterreichFederal RepublicThomas Klestil1,523ATEdit
AZEAzerbaijanAsiaMiddle East86,6001,9917,734,00062.904,1274,100AzərbaycanRepublicİlham Əliyev144AZEdit
BDIBurundiAfricaEastern Africa27,8341,9626,695,00046.20903982Burundi/UburundiRepublicPierre Buyoya552BIEdit
BELBelgiumEuropeWestern Europe30,5181,83010,239,00077.80249,704243,948België/BelgiqueConstitutional Monarchy, FederationAlbert II179BEEdit
BENBeninAfricaWestern Africa112,6221,9606,097,00050.202,3572,141BéninRepublicMathieu Kérékou187BJEdit

Go to page:   


The 'world' database contains three tables, tabulated below:


Field Definitions for Table 'city'
 FieldTypeNullKeyDefaultExtra
0IDintNOPRIauto_increment
1Namechar(35)NO
2CountryCodechar(3)NOMUL
3Districtchar(20)NO
4PopulationintNO0
Field Definitions for Table 'country'
 FieldTypeNullKeyDefaultExtra
0Codechar(3)NOPRI
1Namechar(52)NO
2Continentenum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America')NOAsia
3Regionchar(26)NO
4SurfaceAreadecimal(10,2)NO0.00
5IndepYearsmallintYES
6PopulationintNO0
7LifeExpectancydecimal(3,1)YES
8GNPdecimal(10,2)YES
9GNPOlddecimal(10,2)YES
10LocalNamechar(45)NO
11GovernmentFormchar(45)NO
12HeadOfStatechar(60)YES
13CapitalintYES
14Code2char(2)NO
Field Definitions for Table 'countrylanguage'
 FieldTypeNullKeyDefaultExtra
0CountryCodechar(3)NOPRI
1Languagechar(30)NOPRI
2IsOfficialenum('T','F')NOF
3Percentagedecimal(4,1)NO0.0

Notes

PHP's 'mysqli' extension allows you to access the functionality provided by MySQL 4.1 and above.

More information about the MySQL Database server can be found at http://www.mysql.com/.

Documentation for MySQL is in the doc section of the developer subdomain: http://dev.mysql.com/doc/.

The database 'world' was created from the world database file 'world.sql', available for download from the Example Databases section of the MySQL Web site. A local text copy can be viewed here.

To create a database named 'world' from the 'world.sql' file, first open a cmd terminal in the folder containing the 'world.sql' file, then start the mysql command line client:
> mysql -u [username] -p

Execute the following SQL queries in the mysql command line app:

mysql> CREATE DATABASE world;
mysql> USE world;
mysql> SOURCE world.sql;

Note: In the database file a comment syntax unique to MySQL is employed, e.g.:

     /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

The "/*!40101" at the start of the line means that the following SQL statement will be executed only if the MySQL version is greater than or equal to the specified version number, 4.01.01.
Reference: Comment Syntax in the MySQL Manual.


This PHP script created the following variables from data returned by the query:


$tables - database 'world'

Array
(
    [0] => city
    [1] => country
    [2] => countrylanguage
)

$columns - table 'country'

Array
(
    [0] => Code
    [1] => Name
    [2] => Continent
    [3] => Region
    [4] => SurfaceArea
    [5] => IndepYear
    [6] => Population
    [7] => LifeExpectancy
    [8] => GNP
    [9] => GNPOld
    [10] => LocalName
    [11] => GovernmentForm
    [12] => HeadOfState
    [13] => Capital
    [14] => Code2
)

$key_set

Array
(
    [world] => Array
        (
            [country] => Array
                (
                    [0] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ABW
                                )

                            [cb] => 0
                        )

                    [1] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => AFG
                                )

                            [cb] => 0
                        )

                    [2] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => AGO
                                )

                            [cb] => 0
                        )

                    [3] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => AIA
                                )

                            [cb] => 0
                        )

                    [4] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ALB
                                )

                            [cb] => 0
                        )

                    [5] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => AND
                                )

                            [cb] => 0
                        )

                    [6] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ANT
                                )

                            [cb] => 0
                        )

                    [7] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ARE
                                )

                            [cb] => 0
                        )

                    [8] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ARG
                                )

                            [cb] => 0
                        )

                    [9] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ARM
                                )

                            [cb] => 0
                        )

                    [10] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ASM
                                )

                            [cb] => 0
                        )

                    [11] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ATA
                                )

                            [cb] => 0
                        )

                    [12] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ATF
                                )

                            [cb] => 0
                        )

                    [13] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => ATG
                                )

                            [cb] => 0
                        )

                    [14] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => AUS
                                )

                            [cb] => 0
                        )

                    [15] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => AUT
                                )

                            [cb] => 0
                        )

                    [16] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => AZE
                                )

                            [cb] => 0
                        )

                    [17] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => BDI
                                )

                            [cb] => 0
                        )

                    [18] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => BEL
                                )

                            [cb] => 0
                        )

                    [19] => Array
                        (
                            [keys] => Array
                                (
                                    [0] => BEN
                                )

                            [cb] => 0
                        )

                )

        )

)

$_POST

Array
(
)

$_SESSION

Array
(
    [sort] => Code
)

The PHP script that makes this page work was created and is copyright © 2008, 2009, 2011, 2021, 2023, 2024 by Dennis Langley, Palo Alto, California.