这是我用于连接我的数据库的 oop php 代码。但是我该怎么做这个SELECT
功能。我想在我的页面中显示来自数据库的数据。帮我解决这个问题
class createConnection //create a class for make connection
{
var $host = "localhost";
var $username = "root"; // specify the sever details for mysql
var $password = "";
var $database = "akpGroup";
var $myconn;
function connectToDatabase() // create a function for connect database
{
$conn = mysql_connect($this->host, $this->username, $this->password);
if (!$conn) // testing the connection
{
die ("Cannot connect to the database");
} else {
$this->myconn = $conn;
echo "Connection established";
}
return $this->myconn;
}
function selectDatabase() // selecting the database.
{
mysql_select_db($this->database); //use php inbuild functions for select database
if (mysql_error()) // if error occured display the error message
{
echo "Cannot find the database " . $this->database;
}
echo "Database selected..";
}
function closeConnection() // close the connection
{
mysql_close($this->myconn);
echo "Connection closed";
}