Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. function get_array_needed() {
  2.     $servername = "localhost";
  3.     $username = "algolhos_unisitc";
  4.     $password = "Un1s1t_commerce";
  5.     $dbname = "algolhos_unisitc";
  6.  
  7.     // Create connection
  8.     $conn = new mysqli($servername, $username, $password, $dbname);
  9.     // Check connection
  10.     if ($conn->connect_error) {
  11.         die("Connection failed: " . $conn->connect_error);
  12.     }
  13.  
  14.     $sql = "SELECT codice_target FROM customer";
  15.     $result = $conn->query($sql);
  16.     $rtoclass = array();
  17.  
  18.     if ($result->num_rows > 0) {
  19.         // output data of each row
  20.         while($row = $result->fetch_assoc()) {
  21.             echo "id: " . $row["id_customer"]. " - Codice target: " . $row["codice_target"]."<br>";
  22.             $rtoclass[] = $row;
  23.         }
  24.     } else {
  25.         echo "0 results";
  26.     }
  27.  
  28.     $conn->close();
  29.     return $rtoclass;
  30. }
  31.     $obj->set_arr_needed( get_array_needed() ); // change $obj with the instance name writeToFile() is using...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement