Advertisement
Guest User

Untitled

a guest
Feb 28th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. // Zaharia David
  3. $servername = "127.0.0.1";
  4. $username = "root";
  5. $password = "";
  6. $dataBase = "concurs";
  7. $con = new mysqli ($servername , $username , $password , $dataBase);
  8. if(!$con)
  9. die("Conectare nereusita");
  10. $n=0; // n = nr de judete ;
  11. // parcurgem tabela si memoram toate numele de judete distincte
  12. $interog = "select judet from concurs irder by judet";
  13. $rez = mysqli_query($con , $interog);
  14. while ($linie = mysqli_fetch_array($rez))
  15. {
  16. $x = linie["judet"];
  17. $x = trim($x);
  18. // caut pe x in vectorul de judete
  19. // daca nu apare il adaug
  20. $gasit = 0 ;
  21. for ($i = 0 ; $i < $n && $gasit == 0 ; $i++)
  22. if($a[$i] == $x) $gasit = 1 ;
  23. if ($gasit == 0 )
  24. {
  25. $a[$n] = $x;
  26. $n++;
  27. }
  28. }
  29. for ($i = 0 ; $i < $n ; $i++)
  30. echo $a[$i]."<br>";
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement