Page 1 of 1

About Classes and my example? look at this problem...

Posted: Thu Sep 25, 2003 4:21 pm
by mudkicker

Code: Select all

<?php
class Db
{

var $dbh;
var $dbu;
var $dbp;
var $db;
var $query;
var $show;

	function Db()
	{
	$this->dbh = NOT_SET; 
    $this->dbu = NOT_SET; 
    $this->dbp = NOT_SET; 
    $this->db = NOT_SET;
	}

	function Connect($dbh,$dbu,$dbp,$db)
	{
	@mysql_connect($dbh,$dbu,$dbp) or die("Database Connection Error!");
	@mysql_select_db($db) or die("Database Selection Error!");
	}

	function Close()
	{
	mysql_close();
	}

	function Query($qry)
	{
	$this->query = @mysql_query($qry);
	if(!$this->query)
		{
		echo "Query Error!";
		}
	}

	function Result($no,$break="\n")
	{
	$this->show = mysql_fetch_array($this->query, MYSQL_NUM);
		if(!$no)
		{
		$n = count($this->show);
			for($i=0;$i<$n;$i++)
			{
			echo $this->show[$i].$break;
			}
		}
		else
		{
		echo $this->show[$no];
		}
	}
}

?>
This is my script and i want to add this some functions like MoveNext MoveLPrevious etc.. This will be with the array things etc. but i can't do this can someone have any idea to do this thing?
All replies appreciated. Thank you, have a nice day

Posted: Thu Sep 25, 2003 4:24 pm
by mudkicker
By the way, if you have some suggestions to optimize this current script, write your thoughts down, too! :)