Monkuar Posted February 11, 2012 Share Posted February 11, 2012 $DB->query("SELECT g_title,g_id from ibf_groups where g_title NOT IN ('Validating','Guests') order by rank ASC"); while ($group = $DB->fetch_row()) { $data[$group['g_id']] = $group['g_title']; } $letters2 = $data; var_dump($data); $group=(empty($group))?'':$group; $group.='<center><div class=pages>Group: '; foreach ($letters2 as $letter2) { $group .= '<a href="?a=(^_-)&group='.$letter2.'">'; if (isset($_GET['group']) && $_GET['group'] == $letter2){ echo $letter2; $group .="<b>$letter2</b>"; }else{ $group .="$letter2"; } $group .= '</a>'; if ($letter2!="Loser"){ $group .=" • "; } } var dump: 4 => string 'Admin' (length=5) 8 => string 'Senior Moderator' (length=16) 6 => string 'Moderator' (length=9) 9 => string 'Members+' (length= 7 => string 'Donor' (length=5) 3 => string 'Members' (length=7) 5 => string 'Loser' (length=5) I need the first ARRAY 4, 8,6,9,7,3,5 to be put ontop my link $group .= '<a href="?a=(^_-)&group='.$letters2.'">'; I tried $letter2[$data] and everything for some reason cant get the id there Link to comment https://forums.phpfreaks.com/topic/256884-cant-get-my-g_id-into-my-array/ Share on other sites More sharing options...
trq Posted February 11, 2012 Share Posted February 11, 2012 Takes look at the manual foreach, you can referenc both values and keys easily. Link to comment https://forums.phpfreaks.com/topic/256884-cant-get-my-g_id-into-my-array/#findComment-1316957 Share on other sites More sharing options...
Monkuar Posted February 11, 2012 Author Share Posted February 11, 2012 Takes look at the manual foreach, you can referenc both values and keys easily. Finally some Tough love Coding!!!! foreach ($letters2 as $letter2 => $lol) { $group .= '<a href="?a=(^_-)&group='.$letter2.'">'; if (isset($_GET['group']) && $_GET['group'] == $letter2){ echo $letter2; $group .="<b>$letter2</b>"; }else{ $group .= ''.$letters2[$letter2].''; } $group .= '</a>'; if ($letter2!="Loser"){ $group .=" • "; } } GOt it working! Man these arrays/foreachs are so awesome ! I am so hapy I am actually coding myself now, lol feel sgreat Link to comment https://forums.phpfreaks.com/topic/256884-cant-get-my-g_id-into-my-array/#findComment-1317082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.