php面向对象提问
<?php
include("../conn_inc_php/conn_inc.php");
$database->connect();
$select="select * from login";
$query=mysql_query($select);
if (mysql_num_rows($query)) {
echo "<table border=1>";
echo "<tr>";
echo "<td>账户</td>";
echo "<td>密码</td>";
echo "<td>密码确认</td>";
echo "</tr>";
while ($row=mysql_fetch_assoc($query))
{
echo "<tr>";
echo "<td>".$row['login_name']."</td>";
echo "<td>".$row['password']."</td>";
echo "<td>".$row['password_new']."</td>";
echo "</tr>";
}
}
?>
谁能帮助我把这个面向过程的语句写成面向对象的,我写了很多次都错误,我写的如下,谢谢!!
class php_slelect{
function table($table)
{
$this->query("select * from $table");
}
function query($query){
mysql_query($query);
}
function num($num){
mysql_num_rows($this->query());
}
function fetch($fetch){
if ($this->num()) {
while ($row=mysql_fetch_assoc($this->query($query))){
echo "<td>".$row['login_name']."</td>";
}
}
}
}
$select=new php_slelect();
$select->table('login');
$select->fetch();
老出现错误,我现在都搞不明白了大家能给我一个参考吧!!