Re: creating an array from a mysql result
| From: | Joe Stump | Date: | Mon, 30 Oct 2000 07:28:42 +0000 |
| Subject: | Re: creating an array from a mysql result | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22621@lists.php.net to get a copy of this message | ||
This might work :O)
while($row = mysql_fetch_row($details)){
// this puts the ENTIRE array $row into
// an array called $array_of_rows
$array_of_rows[] = $row;
$fieldName = 'field';
$n = 0;
while(list($key,$val) = each($row)){
$field = $fieldName.$n;
$$field = $val;
if($n == 2){
$$field[] = $row;
}
++$n;
}
}
--Joe
On Mon, Oct 30, 2000 at 03:47:22PM +1030, joeb wrote:
> Hey all,
>
> I was wondering on how to do the following:
>
> while ( $row = mysql_fetch_row($details) ) {
> $field0=$row[0];
> $field1=$row[1];
> $field2[]=$row[2];
> $field3=$row[3];
> $field4=$row[4];
> $field5=$row[5];
> $filed6=$row[6];
> }
>
> *Note I am trying to put field2 into an array
>
> if ( in_array ($value, $field2) ) {
> Do something
> }
>
> for some reason I can't get this to work I thought that for each loop of the
> while a value would be added can the above actually be done or will I have
> to try something else.
>
> I don't want to use mysql_fetch_array() as this is a overly complex way to
> get one field into an array and I have the worst flu at the moment my head
> feels like it is going to explode.
>
> Any help would be a godsend,
>
> Regards
>
> Joseph
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
================================================================================
= Joe Stump joestump98@yahoo.com http://www.miester.org =
================================================================================
"Real programmers don't comment their code.
It was hard to write, it should be hard to understand."