Advertisement
Guest User

Untitled

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