Web Design Forums

Welcome! Please register or log in: Forgot your password? Why register?
You are here: Web Design Forums » Programming Help » PHP » MySql Class RSS

MySql Class

This thread was started by hollen949b and has been viewed 298 times, and contains 1 replies, with the last reply made by hollen949b.
Post Reply
1
View hollen949b's reputation
Posted January 21 '10 at 12:36 AM
      Posts: 7
How would I go about getting the same results from

class newCats {
        public 
$go;
        private 
$id;
        public function 
__construct() {
            
$this->go uniqid();
        }
        public function 
listData() {
            return 
"id: {$this->id} go: {$this->go}";
        }    
    }
    
$result mysql_query(    
        
"SELECT * FROM wr_categories ".
        
"ORDER BY ordering" 
    
);
    while(
$obj mysql_fetch_object($result'newCats') ){
         echo 
$obj->listData()."<br /> \n";
    } 

but putting

$result mysql_query(    
        
"SELECT * FROM wr_categories ".
        
"ORDER BY ordering" 
    
); 

in its own function within my newCats class?

Advertisement Register for free to hide these ads and participate in discussions!

2
View hollen949b's reputation
Posted January 21 '10 at 03:57 PM
      Posts: 7
In my defense it was late when i posted this question .... tah timmahhh!!!
class newCats {
        public 
$go;
        private 
$id;
        public function 
__construct() {
            
$this->go uniqid();
        }
        public function 
listData() {
            return 
"id: {$this->id} go: {$this->go}";
        }   
        public function 
select(){
            return 
mysql_query(    
                
"SELECT * FROM wr_categories ".
                
"ORDER BY ordering" 
            
);
        }
    }
    
$qry = new newCats();
    
$result $qry->select();
    while(
$obj mysql_fetch_object($result'newCats') ){
         echo 
$obj->listData()."<br /> \n";
    } 

Post Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add, View, Edit & Delete from to MySQL database, Live Example (News System) making MySQL and MaxDB 7 January 5 '09 10:59 AM
Class Object in Session vs Load time toadeny PHP 1 October 5 '04 01:51 PM