RE: [PHP] pulling data from array

From: Date: Mon, 08 Sep 2008 19:48:39 +0000
Subject: RE: [PHP] pulling data from array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-279692@lists.php.net to get a copy of this message
> -----Original Message----- > From: Jim Lucas [mailto:lists@cmsws.com] > Sent: Monday, September 08, 2008 2:38 PM > To: Richard Kurth > Cc: PHP General List > Subject: Re: [PHP] pulling data from array ---8<--- snip > > $query1 = "SELECT sponserrep,rep,firstname,lastname,phonenumber FROM > > contacts WHERE members_id = '8' AND sponserrep != ''"; > > $result1=mysql_query($query1); > > $num_rows = mysql_num_rows($result1); > > while($row1=mysql_fetch_array($result1)){ > > Change the previous line to this > > while ( $row1 = mysql_fetch_assoc($result1) ) { > > > $customf_array[]=$row1[0] . "," . $row1[1] . "," . $row1[2] . > > "," .. > > $row1[3]; > > Change the previous line to this > > $customf_array[] = $row1; Gahhh... I've been working with ASP.NET too much recently. I didn't even see that he wasn't fetching the row as an associative array. I seem to remember using mysql_fetch_row() for it when I was doing more PHP/DB-oriented coding. Object instantiation to contain a row of information that could already be accessed methodically and easily was a bit of overkill in my "solution." :) Cheers, Todd Boyd Web Programmer

« previous php.general (#279692) next »