Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 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. else
  25. {
  26. $query = "Select DISTINCT Genus FROM Tennessee WHERE State='$state_name' AND County='$county_name'";
  27. }
  28. //}
  29. //if(isset($_GET["county"]) && isset($_GET["county"])!="SelectALL"){
  30. //$county_name=mysql_real_escape_string ($_GET["county"]);
  31. //$query.=" AND County='".$county_name."'";
  32. //}
  33. echo $query;
  34. $result = mysql_query($query);
  35. //var_dump($result);
  36. //echo $result;
  37. if(!$result){
  38. die('Invalid query: ' .mysql_error());
  39. }
  40. ?>
  41.  
  42. <select name="genus" onChange="display(this.value)">
  43. <option> Select Genus</option>
  44. <?while($row=mysql_fetch_array($result)){?>
  45. <option><?=$row['Genus']?></option>
  46. <?}?>
  47. </select>
  48.  
  49. <?php
  50. echo "<table border='1'>";
  51. /*echo '<tr><th>StateName</th><th>CountyName</th><th>Fips</th><th>Count</th><th>Entries</th><th>Category</th><th>ID1</th><th$
  52. while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
  53. {
  54. echo "<tr>";
  55. echo '<td>' .  $row['ID1'] . '</td>';
  56. echo '<td>' .  $row['ID'] . '</td>';
  57. echo '<td>' .  $row['Family'] . '</td>';
  58. echo '<td>' .  $row['Genus'] . '</td>';
  59. echo '<td>' .  $row['Species'] . '</td>';
  60. echo "</tr>";
  61. }
  62. echo "</table>";
  63. mysql_close($connection);
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement