User Tools

Site Tools


get-countries-by-continent

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

get-countries-by-continent [2016/05/10 15:59] (current)
mh created
Line 1: Line 1:
 +<​code>​
 +<?php
 +$dbh = mysqli_connect("​127.0.0.1",​ "​world",​ "​world",​ "​world"​);​
 +$result = $dbh->​query('​select distinct(Continent) as c from country'​);​
 +?>
 +<​form ​
 +  name="​countrysearchform" ​
 +  id="​countrysearchform"​
 +  action="<?​php echo $_SERVER['​PHP_SELF'​];?>"​
 +  method="​GET">​
  
 +  <select name="​continent"​ id="​continent">​
 +  <?php
 +  while ($row = $result->​fetch_assoc()) {
 +  printf('<​option value="​%s">​%s</​option>',​ $row['​c'​],​ $row['​c'​]);​
 +  } 
 +  $result->​close();​
 +  ?>
 +  <br>
 +  <​p><​input type="​submit"​ value="​Search"></​p>​
 +  </​select>​
 +</​form>  ​
 +</​code>​
get-countries-by-continent.txt ยท Last modified: 2016/05/10 15:59 by mh