Re: [PHP-DB] Help: Two dimensional array from table
am 07.04.2006 20:59:32 von Mark Fellowes------=_EDNP_0000_7d443810-3dd9-40a7-b330-51d1d5f8787d
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
ï»=BFThe reason I had orginally singled out one column ['usr_d'] is=
so I could nest it inside another loop to see if two values match. if=
usr_id matched returned value from first loop.=0AThe way I called it=
was if(!in_array(@$row_rsResults['id_subscribe'],$usrreg)) {=0Aelse{...=
..............
now Im not sure how to call the individual fields.=
I've tried $usrreg['date']; but that doesn't seem to work.=0ADo I need=
to use keys and values ?
TIA=0AMark
-----Original Messa=
ge-----=0AFrom: micah@raincross-tech.com=0ASent: Friday, April 7, 2006=
4:14 PM -07:00=0ATo: Mark Fellowes [Zanoni@goowy.com]=0ASubject: [PHP-D=
B] Help: Two dimensional array from table
=0AYes, all wrong.
T=
he array that mysql_fetch_assoc returns is one dimensional. Not two. So=
=0Ayou can refer to it like you are. Your problem is in your query more=
=0Athan anything. You're doing things the hard way. Keep in mind that=
=0Amysql_fetch_assoc will take care of column names for you so:
$r=
s_usr_usr =3D mysql_query("select user_id, usr_date from table");
/=
/Code for registered=0A$usrreg =3D array();=0Ado {=0A $usrreg[] =3D $row=
_usr_usr;=0A} while($row_rs_usr_usr =3D mysql_fetch_assoc($rs_usr_usr));=
=0A//end of registered
That's all you need.=0A-Micah
Mar=
k Fellowes wrote:=0A> I created an array to pull data out of one column=
in database.=0A>=0A> //Code for registered=0A> $usrreg=
id =3D array();=0A> do {=0A> $usrregid[] =3D $row_rs_usr_usr["usr_id"];=
=0A> } while($row_rs_usr_usr =3D mysql_fetch_assoc($rs_usr_usr));=0A>=
//end of registered=0A> ?>=0A>=0A> However I now need a second column=
from the table and think a two dimensional array is the right way to=
go. Having a problem though in defining. Most of the examples I found=
don't seem to apply to pulling the values from a db.=0A>=0A> I tried=
this and while it returns no errors, it also returns no value.=0A>=0A>=
//Code for registered=0A> $usrreg =3D array("id", "date");=
=0A> do {=0A> $usrreg[] =3D $row_rs_usr_usr["usr_id"]["usr_date];=0A>=
} while($row_rs_usr_usr =3D mysql_fetch_assoc($rs_usr_usr));=0A> //end=
of registered=0A> ?>=0A>=0A> Am I defining wrong or pulling the values=
wrong ?=0A>=0A> TIA=0A> Mark=0A> ______________________________________=
____=0A> Organize. Communicate. Share. @ http://www.goowy.com=0A>
__________________________________________
Organize. Communicate. Share. @ http://www.goowy.com
------=_EDNP_0000_7d443810-3dd9-40a7-b330-51d1d5f8787d--