Jump to content

cant get my g_id into my array


Monkuar

Recommended Posts

$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=8)

  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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.