mysql query class -> result repeats to infinity
Posted: Wed Nov 14, 2007 9:42 am
Hi,
could anyone tell me, where's my problem?
class file:
I want this class to display all table's rows.
The displaying page :
The result is displaying the first table row, for infinity times.
It doesn't get to the 2nd and other rows.
It works fine, when i replace
with
but i don't want to write this everytime. 
could anyone tell me, where's my problem?
class file:
Code: Select all
class klase
{
function connect()
{
$this->dbconn = mysql_connect("localhost", "root");
}
function selectdb($db)
{
$this->sdb = mysql_select_db ($db, $this->dbconn);
}
function query($query)
{
$this->qres = mysql_query ($query, $this->dbconn);
$this->rez = mysql_fetch_object ($this->qres);
}
}The displaying page :
Code: Select all
<?php
include("classfile.php");
$xxx = new klase;
$xxx->connect(100);
$xxx->selectdb("Mokymai");
$xxx->query("select * from 2g");
while($xxx->rez)
{
print $xxx->rez->id ;
print $xxx->rez->name ;
print $xxx->rez->type ;
print $xxx->rez->description ;
print "<br>" ;
}
?>It doesn't get to the 2nd and other rows.
It works fine, when i replace
Code: Select all
while($xxx->rez)with
Code: Select all
while($xxx->rez = mysql_fetch_object ($xxx->qres))