Advertisement
semdev

class

Apr 3rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php
  2. /** SMS **/
  3.  
  4. class SMS
  5. {
  6.     function __construct()
  7.     {
  8.  
  9.         try {
  10.             $this->host = 'localhost';
  11.             $this->dbname = 'icodeja_sms';
  12.             $this->user = 'icodeja_sms';
  13.             $this->pass = '2LosMI6d';
  14.             $this->DBH = new PDO("mysql:host=$this->host;dbname=$this->dbname", $this->user, $this->pass);
  15.  
  16.  
  17.         } catch (PDOException $e) {
  18.  
  19.             echo $e->getMessage();
  20.         }
  21.     }
  22.  
  23.     public function get_user_data()
  24.     {
  25.         $user_data = [];
  26.         $data = $this->DBH->query("SELECT * FROM users")->fetchAll(PDO::FETCH_OBJ);
  27.         foreach ($data as $user) {
  28.  
  29.             $user_data = [
  30.                 'username' => $user->usr_name,
  31.                 'uid' => $user->usr_id,
  32.                 'user_created' => $user->usr_created,
  33.                 'usr_active' => $user->usr_active
  34.             ];
  35.  
  36.  
  37.         }
  38.  
  39.     }
  40.  
  41.     public function select_data($where)
  42.     {
  43.         $data = $this->DBH->query("SELECT * FROM $where")->fetchAll(PDO::FETCH_ASSOC);
  44.         $results = array();
  45.  
  46.         foreach ($data as $quiried_data) {
  47.             array_push($results, $quiried_data);
  48.  
  49.         }
  50.         return $results;
  51.     }
  52.  
  53.     public function build_filter_userList(){
  54.  
  55.         $data = $this->select_data('users');
  56.         foreach ($data as $user_data){
  57.             echo '<option id="'.$user_data['usr_id'].'-'.$user_data['usr_name'].'" name="'.$user_data['usr_id'].'">'.$user_data['usr_name'].'</option>';
  58.         }
  59.  
  60.     }
  61.     public function build_filter_country_list(){
  62.  
  63.         $data = $this->select_data('countries');
  64.         foreach ($data as $country_data){
  65.             echo '<option id="'.$country_data['cnt_id'].'-'.$country_data['cnt_code'].'" name="'.$country_data['cnt_code'].'">'.$country_data['cnt_title'].'</option>';
  66.         }
  67.  
  68.     }
  69. }
  70.  
  71.  
  72. $sms = new SMS();
  73. $sms->build_filter_country_list();
  74. $sms->build_filter_userList();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement