I figured out the mistake and I fixed it.
Thanks Marco for atleast making an effort to help.
I ran into another problem but I got it situated.
I'm posting the working code here for two reasons. One is if I lose the code and the other is for other people to look at.
I wanted to use "left join" but the query got to be too complicated for me.
PHP Code:
$last_cat = '0';
$getdroplinks_cat = $db->query_read("SELECT *
FROM " . TABLE_PREFIX . "custom_droplinks_cat ORDER BY catid");
while($dlink = $db->fetch_array($getdroplinks_cat))
{
$dlink['permissions'] = explode(",", $dlink['permissions']);
if($last_cat != $dlink['catid'])
{
if(in_array($vbulletin->userinfo['usergroupid'], $dlink['permissions']) )
{
eval('$custom_droplinks_cat .= "' . fetch_template('custom_droplinks_cat') . '";');
}
}
$custom_droplinks_bit .= "<div class='vbmenu_popup' id='adv$dlink[catid]menu_menu' style='display:none'>
<table cellpadding='4' cellspacing='1' border='0'>
<tr><td class='thead'>".$dlink['title']."</td></tr>";
$getdroplink_bits = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "custom_droplinks WHERE catid = '$dlink[catid]' ");
while($droplink_bits = $db->fetch_array($getdroplink_bits))
{
if($droplink_bits['new_window'] == 1)
{
$new = "_blank";
}
else
{
$new = "";
}
if(!empty($droplink_bits['image']))
{
$img = "<img src='".$droplink_bits['image']."' width='16' height='16' />";
}
else
{
$img = "";
}
$droplink_bits['link_perms'] = explode(",", $droplink_bits['link_perms']);
if(in_array($vbulletin->userinfo['usergroupid'], $droplink_bits['link_perms']) )
{
$custom_droplinks_bit .=
"<tr><td class='vbmenu_option'>$img<a href='".$droplink_bits['url']."' target='$new' title='".$droplink_bits['alt']."'>".$droplink_bits['name']."</a></td></tr>";
}
}
$custom_droplinks_bit .= "</table></div>";
eval('$custom_droplinks = "' . fetch_template('custom_droplinks') . '";');
$last_cat = $dlink['catid'];
}