Posted by nithin on 08/29/07 05:57
Hi i tried with your coding in my local server its working fine for
me..
I thing you may gone wrong some other part of the coding...
test using the following code:
create a database: testdb
A table users add a field 'username'
then try with this coding bellow
<?php
$con = mysql_connect('localhost','root','');
$db = mysql_select_db('testdb');
class test {
private $_result;
private $_record;
public function __construct($result) {
$this->_result = $result;
}
public function show() {
while($this->_record = mysql_fetch_array($this->_result)) {
echo $this->_record['username'].'<br />';
}
}
}
# usage
# sql statement dat artikels ophaald uit cartal database
$sql = "SELECT * FROM users";
# uitvoeren van dit statement
$RESULT = mysql_query($sql);
$t = new test($RESULT);
$t->show();
?>
Navigation:
[Reply to this message]
|