我正在尝试将数据库行插入到对象中,但我不明白这里有什么问题:(我看不到输出)。
<body>
<?php header('Content-Type: text/html; charset=utf-8');
include("dash_class.php");
mysql_connect("localhost", "root", "") or
die("Could not connect: " . mysql_error());
mysql_select_db("msordash");
mysql_query("SET NAMES 'utf8'");
$dashim=mysql_query("SELECT * FROM dash");
while ($row = mysql_fetch_array($dashim)) {
$dash=new dash($row["name"],$row["msg"],$row["msg_date"]);
echo $dash->name;
}
?>
</body>
类代码:
class dash
{
public $name;
public $msg;
public $msg_date;
function __constractor($name,$msg,$msg_date){
$this->name=$name;
$this->msg=$msg;
$this->msg_date=$msg_date;}
}
?>