whit Posted October 31, 2010 Share Posted October 31, 2010 Ok guys and gals I'm gettin' old! I know this is simple but I've spent way too much time on this now and am crying 'uncle'! I'm trying load a multi-dementional array with mysql_fetch_array results but I'm not getting it. Here's the rough basis for what I'm trying to do: $result = mysql_query("SELECT * FROM phpbb_profile_fields_data"); $row = mysql_fetch_array($result) or die(mysql_error()); $some_array = array( array( 'member_name' => $row['pf_firstname'] . " " . $row['pf_lastname'], 'member_title' => $row['pf_title'], 'member_employer' => $row['pf_employer'], ), array( 'member_name' => 'Janet', 'member_title' => '47', 'member_employer' => 'Husband', ), ); Okay, so that loads two $some_array elements with data. The first element has the first row of the database in question. Works fine but useless. So, with a "while ($row = mysql_fetch_array($result) )" what do I need to do to fill the $some_array with the query results? Thanks! Link to comment https://forums.phpfreaks.com/topic/217383-simple-loopsqlarray-question/ Share on other sites More sharing options...
jcbones Posted October 31, 2010 Share Posted October 31, 2010 $some_array[] = array( 'member_name' => $row['pf_firstname'] . " " . $row['pf_lastname'], 'member_title' => $row['pf_title'], 'member_employer' => $row['pf_employer'] ) *clarification* To display this: foreach($some_array as $value) { echo $value['member_name']; //etc. } Link to comment https://forums.phpfreaks.com/topic/217383-simple-loopsqlarray-question/#findComment-1128726 Share on other sites More sharing options...
whit Posted October 31, 2010 Author Share Posted October 31, 2010 $some_array[] = array( 'member_name' => $row['pf_firstname'] . " " . $row['pf_lastname'], 'member_title' => $row['pf_title'], 'member_employer' => $row['pf_employer'] ) omg! Put that inside the loop? Link to comment https://forums.phpfreaks.com/topic/217383-simple-loopsqlarray-question/#findComment-1128727 Share on other sites More sharing options...
jcbones Posted October 31, 2010 Share Posted October 31, 2010 Yes. Link to comment https://forums.phpfreaks.com/topic/217383-simple-loopsqlarray-question/#findComment-1128728 Share on other sites More sharing options...
whit Posted October 31, 2010 Author Share Posted October 31, 2010 THANK YOU! Link to comment https://forums.phpfreaks.com/topic/217383-simple-loopsqlarray-question/#findComment-1128729 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.