Hi Jeromie,
Thank you for suggesting the PEAR DB class, I will
study that option. As for this script, I have done the
following but it is not printing anything.
/***** script file ******************/
// snip
$row=$datbs->show();
ECHO $row['id'];
ECHO $row['Date'];
ECHO $row['Name'];
ECHO " <br>";
/***** class "datbs" ******************/
function show()
{
// snip
while ($row = mysql_fetch_array($this->result))
{ $result[] = $row; }
return $row;
// snip
}
/***** ******************/
--- Jeromie Clark <[EMAIL PROTECTED]> wrote:
---------------------------------
Hi -
There are a couple problems here:
1.) Return exits and returns the value immediately, so
you're never
going to get to the 2nd row.
2.) You can only pass one thing back from the
function, so you probably
want to assemble an array of values.
>/***** class "datbs" ******************/
>
>function show()
>{
>// snip
>while ($this->row = mysql_fetch_array($this->result))
> {
> return ($this->row);
> }
>
>// snip
>}
>
Try this:
function show()
{
// $this-> is for accessing/placing a variable in
the class scope.
// You probably don't need to place $row in the
class scope for the
purposes of assembling a result set to pass back.
while ($row = mysql_fetch_array($this->result))
{
$result[] = $row; // this creates an ordered
array, appending
each new value to the end of the array.
}
return $row; // Pass the array you've assembled
back
}
On another note, the PEAR DB class is a really nice
database abtraction
class.
If you're looking for a nice OO way to interact with
the database,
they've done a good job with it.
http://pear.php.net/manual/en/
___________________________________________________________
Yahoo! Photos NEW, now offering a quality print service from just 8p a photo
http://uk.photos.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/KIlPFB/vlQLAA/TtwFAA/CefplB/TM
--------------------------------------------------------------------~->
The php_mysql group is dedicated to learn more about the PHP/MySQL web database
possibilities through group learning.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php_mysql/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/