Advertisement
leox99x

Untitled

May 27th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. <?php
  2. class SelectList
  3. {
  4.  
  5. protected $conn;
  6.  
  7. public function __construct()
  8. {
  9. $this->DbConnect();
  10. }
  11.  
  12. protected function DbConnect()
  13. {
  14. include "db_config.php";
  15.  
  16. $this->conn = mysql_connect($host,$user,$password) OR die("Impossibile connettersi al database");
  17. mysql_select_db($db,$this->conn) OR die("Impossibile selezionare il database $db");
  18.  
  19. return TRUE;
  20. }
  21.  
  22. public function ShowRegioni()
  23. {
  24. $sql = "SELECT * FROM regioni";
  25. $res = mysql_query($sql,$this->conn);
  26. $regioni = '<option value="0">scegli...</option>';
  27.  
  28. while($row = mysql_fetch_array($res))
  29. {
  30. $regioni .= '<option value="' . $row['id_regioni'] . '">' . utf8_encode($row['nome_regioni']) . '</option>';
  31. }
  32.  
  33. return $regioni;
  34. }
  35.  
  36. public function ShowProvince()
  37. {
  38. $sql = "SELECT * FROM provincie WHERE fk_regioni=$_POST[id_regioni]";
  39. $res = mysql_query($sql,$this->conn);
  40. $province = '<option value="0">scegli...</option>';
  41.  
  42. while($row = mysql_fetch_array($res))
  43. {
  44. $province .= '<option value="' . $row['id_provincie'] . '">' . utf8_encode($row['nome_provincie']) . '</option>';
  45. }
  46.  
  47. return $province;
  48. }
  49.  
  50. public function ShowComuni()
  51. {
  52. $sql = "SELECT * FROM comuni WHERE fk_provincie=$_POST[id_provincie]";
  53. $res = mysql_query($sql,$this->conn);
  54. $comuni = '<option value="0">scegli...</option>';
  55.  
  56. while($row = mysql_fetch_array($res))
  57. {
  58. $comuni .= '<option value="' . $row['id_comuni'] . '">' . utf8_encode($row['nome_comuni']) . '</option>';
  59. }
  60.  
  61. return $comuni;
  62. }
  63.  
  64. public function ShowIstituti()
  65. {
  66. $sql = "SELECT * FROM istituti WHERE fk_comuni=$_POST[id_comuni]";
  67. $res = mysql_query($sql,$this->conn);
  68. $istituti = '<option value="0">scegli...</option>';
  69.  
  70. while($row = mysql_fetch_array($res))
  71. {
  72. $istituti .= '<option value="' . $row['id_istituti'] . '">' . utf8_encode($row['nome_istituti']) . '</option>';
  73. }
  74.  
  75. return $istituti;
  76. }
  77.  
  78. public function ShowScuole()
  79. {
  80. $sql = "SELECT * FROM scuole WHERE fk_istituti=$_POST[id_istituti]";
  81. $res = mysql_query($sql,$this->conn);
  82. $scuole = '<option value="0">scegli...</option>';
  83.  
  84. while($row = mysql_fetch_array($res))
  85. {
  86. $scuole .= '<option value="' . $row['id_scuole'] . '">' . utf8_encode($row['denominazione']) . '</option>';
  87. }
  88.  
  89. return $scuole;
  90. }
  91.  
  92. public function ShowPlessi()
  93. {
  94. $sql = "SELECT * FROM plessi WHERE fk_scuole=$_POST[id_scuole]";
  95. $res = mysql_query($sql,$this->conn);
  96. $plessi = '<option value="0">scegli...</option>';
  97.  
  98. while($row = mysql_fetch_array($res))
  99. {
  100. $plessi .= '<option value="' . $row['id_plessi'] . '">' . utf8_encode($row['nome_plessi']) . '</option>';
  101. }
  102.  
  103. return $plessi;
  104. }
  105.  
  106. }
  107.  
  108. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement