Re: How to use a Class?

From: Date: Fri, 04 Apr 2003 15:46:45 +0000
Subject: Re: How to use a Class?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26832@lists.php.net to get a copy of this message
Hi Shantanu To be honest you'd be far better off doing this manually, rather than using someone elses code - quite important bits and pieces of sql and db access logic which you'll need to learn, but .... On 03 Apr,2003 at 20:18 Shantanu Oak wrote: <snip> > the following code mentioned on the page, > > $mysearch = new MysqlSearch; > $mysearch->setidentifier("MyPrimaryKey"); > $mysearch->settable("MyTable"); > $results_array = $mysearch->find($mysearchterms); > > I am getting the text array() as a result. </snip> This is php telling you that the variable is of the array type, ie: it is a variable containing many indexed values. BTW, have you changed the setidentifier() and settable() values to the correct ones for your db ? (just checking). <snip> > Can someone explain to me how to use it and get > result. </snip> A handy utility function is var_dump(). This will echo out the contents of any variable type. So to display the contents of your $results_array variable you would do:- <?php echo "<pre>"; var_dump($results_array); echo"</pre>"; ?> That'll show you the contents of the array and what its structure looks like. Displaying it in a controlled form is just a matter of finding out the structure of the array and looping through it using one of php's many many loop constructs / array access functions. Have a read about arrays on www.php.net - they are very useful once you get the hang of them ... ;-) <snip> > > Shantanu Oak > shantanuo@yahoo.com > http://www.shantanuoak.com Cheers -- Ronan e: ronan@thelittledot.com t: 01903 739 997 w: www.thelittledot.com The Little Dot is a partnership of Ronan Chilvers and Giles Webberley

« previous php.db (#26832) next »