RE: pulling data from array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Jim Lucas [mailto:lists@xxxxxxxxx]
> Sent: Monday, September 08, 2008 2:38 PM
> To: Richard Kurth
> Cc: PHP General List
> Subject: Re:  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




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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux