Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1.  
  2. <?php
  3. error_reporting ( E_ALL );
  4. $connection = mysql_connect('localhost',"sernec","sernec");
  5. if(!$connection){ die('Not connected : '.mysql_error()); }
  6.  
  7. $db_selected = mysql_select_db("SERNEC",$connection);
  8. if(!$db_selected){  die('Cant use db: '.mysql_error()); }
  9.  
  10. if (isset($_GET["state"])) {
  11.     $state_name = mysql_real_escape_string ($_GET["state"]);
  12. //  echo $_GET['state'];
  13. }
  14. $query = "Select DISTINCT Genus FROM Tennessee";
  15. if(isset($_GET["county"])){
  16. if(isset($_GET["county"])!="SelectALL" ){
  17. $county_name=mysql_real_escape_string ($_GET["county"]);
  18. $query = "Select DISTINCT Genus FROM Tennessee WHERE State='$state_name' AND County='$county_name' ORDER BY Genus";
  19. }
  20.  //echo $_GET['county']
  21. else
  22. $query = "Select DISTINCT Genus FROM Tennessee WHERE State='".$state_name."' ORDER BY Genus";
  23. }
  24. $result = mysql_query($query);
  25. if(!$result){
  26. die('Invalid query: ' .mysql_error());
  27. }
  28. ?>
  29.  
  30. <select name="genus" onChange="display(this.value)">
  31. <option> Select Genus</option>
  32. <?while($row=mysql_fetch_array($result)){?>
  33. <option><?=$row['Genus']?></option>
  34. <?}?>
  35. </select>
  36.  
  37. <?php
  38. echo "<table border='1'>";
  39. /*echo '<tr><th>StateName</th><th>CountyName</th><th>Fips</th><th>Count</th><th>Entries</th><th>Category</th><th>ID1</th><th>ID</th><th>Family</th><th>Genus</th><th>Sp$
  40. while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
  41. {
  42. echo "<tr>";
  43. echo '<td>' .  $row['ID1'] . '</td>';
  44. echo '<td>' .  $row['ID'] . '</td>';
  45. echo '<td>' .  $row['Family'] . '</td>';
  46. echo '<td>' .  $row['Genus'] . '</td>';
  47. echo '<td>' .  $row['Species'] . '</td>';
  48. echo '<td>' .  $row['ScientificNameAuthor'] . '</td>';
  49. echo '<td>' .  $row['Subspecies'] . '</td>';
  50. echo '<td>' .  $row['Variety'] . '</td>';
  51. echo '<td>' .  $row['Country'] . '</td>';
  52. echo '<td>' .  $row['State'] . '</td>';
  53. echo '<td>' .  $row['County'] . '</td>';
  54. echo '<td>' .  $row['Collector'] . '</td>';
  55. echo '<td>' .  $row['Locality'] . '</td>';
  56. echo '<td>' .  $row['Latitude'] . '</td>';
  57. echo '<td>' .  $row['Longitude'] . '</td>';
  58. echo '<td>' .  $row['InstitutionalCode'] . '</td>';
  59. echo '<td>' .  $row['CollectionCode'] . '</td>';
  60. echo '<td>' .  $row['CatalogueNumber'] . '</td>';
  61. echo "</tr>";
  62. }
  63. echo "</table>";
  64. mysql_close($connection);
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement