Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class cmain{
- private $host;
- private $user;
- private $pass;
- private $db;
- public function get($host,$user,$pass,$db){
- echo $this->host = $host;
- echo $this->user = $user;
- echo $this->pass = $pass;
- echo $this->db = $db;
- }
- public function __construct() {
- $this->link = mysql_connect("$this->host","$this->user","$this->pass");
- mysql_select_db($this->db,$this->link);
- }
- public function select ($tbl,$uid){
- $this->tbl = $tbl;
- $this->uid = $uid;
- if (empty($this->uid))
- $this->result = mysql_query("SELECT * FROM $this->tbl")or die (mysql_error());
- if (!empty($this->uid))
- $this->result = mysql_query("SELECT * FROM $this->tbl WHERE id='$this->uid'")or die (mysql_error());
- $this->return = array () ;
- while ($this->row = mysql_fetch_array( $this->result )) {
- $this->return [] = $this->row ;
- }
- return ($this->return);
- }
- public function __destruct() {
- mysql_close($this->link);
- }
- }
- $con = new cmain();
- require_once 'config.php';
- $con->get(host, user, pass, db);
- $tbl = "members";
- $result = $con->select($tbl, $_SESSION['user']);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement