Yeah, that was my bad... I meant $result.
>Jeromie,
>
>Your method actually works, thank you, I only had to
>add:
>foreach($row AS $key => $val) and it worked fine.It
>looks like this now: (please note that return $row
>didn't work for some reason (see below).. I changed it
>to return $result and its fine)
>
>/***** script file ******************/
>// snip
>$row=$datbs->show();
> foreach($row AS $key => $val )
> {
> echo ($val[0]. " " . $val[1]. " " .
>$val[2]. "<br>");
> }
>
>/***** class "datbs" ******************/
>function show()
>{
>// snip
> while ($row = mysql_fetch_array($this->result))
> {$result[] = $row;}
>
> return $result; // return $row didn't worrk ?
>// snip
>}
>/***** ******************/
>
>Thank you for your help.
>David
>
>
>--- David Halliday <[EMAIL PROTECTED]> wrote:
>
>---------------------------------
>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! Exclusive Xmas Game, help Santa with his celebrity party -
>http://santas-christmas-party.yahoo.net/
>
>
>
>The php_mysql group is dedicated to learn more about the PHP/MySQL web
>database possibilities through group learning.
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income homes are not online. Make a difference this holiday season!
http://us.click.yahoo.com/5UeCyC/BWHMAA/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/