<title>World Database List Government Types</title>
<h3>World Database Small Countries</h3>
// Open the Database, selecting the World2 database
$con = mysqli_connect("localhost","demo","demo","world2");
if (!$con)
    die("Could not connect: " . mysqli_error($con));

$maxpop = 100000;  // Largest country to include

echo "<h4>List all government types</h4>";

$query = "SELECT DISTINCT GovernmentForm, COUNT(*) AS Num FROM Country GROUP BY Gover
nmentForm ORDER BY Num DESC";

echo $query."<br>";

//Lookup the matches
$result = mysqli_query($con,$query);

//Check if there was a match
if (!$result) {
   die("No matches");
//Display the results
echo "<table border=1>";
echo "<tr><th>Government Form</th><th>Number of Countries</th></tr>";

while ($Row=mysqli_fetch_assoc($result)) {
   echo "<tr><td>{$Row['GovernmentForm']}</td>";
   echo "<td>{$Row['Num']}</td>";
echo "</table>";

<input type="button" value="New search" onClick="parent.location='countrymenu.php'">
Topic revision: r1 - 2013-11-22 - JimSkon
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback