How to display data on the page without putting code to display data in class definition
I have function with simple sql query to list tickets on the page:
class DBQuery { function displayTicketsList(){ $this->dbConnection(); $query = "SELECT * FROM tickets"; $this->result = mysql_query($query); $this->dbClose(); } . . . }
How to display data on the 开发者_StackOverflow社区page without putting code to display in class definition.
Your question isn't that clear, but I think you mean something like this:
class DBQuery
{
function displayTicketsList(){
$this->dbConnection();
$query = "SELECT * FROM tickets";
$this->result = mysql_query($query);
$this->dbClose();
return $this->result;
}
.
.
.
}
and then in your "view", or whatever:
$myClass=new DBQuery;
$foo=$myClass->displayTicketsList();
print_r($foo);
精彩评论