Thomas Hochstetter wrote:
> Hi guys,
> 
> I wrote a generic getsql() function for my project's class. However, I
> only manage to retrieve a single row. What it should really do is:
> Read all rows into the array (with multiple results). The code is
> below: 
> 
> function getsql($sql,$conn,$dbase,&$arr)
> {
>             if($conn)
>             {
>                         mysql_select_db($dbase,$conn);
>                         $result = mysql_query($sql,$conn);
> 
>                         while ($arr = mysql_fetch_assoc($result))    
>                                     { return $arr;
> // Something has to happen here!!!
>                         }
>             }

I think your problem is that you are returning after the first row has been
read, what you need to do is add the row ($arr) to another array using
$new_array[] = $arr or similar. and then move the return $arr to after the
while loop, but then return $new_array not $arr.

Hope this makes sense.

Alastair


==============================================================================
IMPORTANT NOTICE

The information contained in this e-mail is confidential. It may also
be legally privileged. It is intended only for the stated
addressee(s) and access to it by any other person is unauthorised. If
you are not an addressee, you must not disclose, copy, circulate or
in any other way use or rely on the information contained in this
e-mail. Such unauthorised use may be unlawful.

If you have received this e-mail in error, please inform
Racal Instruments Ltd. immediately by emailing
[EMAIL PROTECTED] or phoning +44 (0)1628 604455 (ask
for the I.T. Dept.) and delete it and all copies from your system.

www.racalinstruments.com

==============================================================================


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to