I thought I could apply the solution Marco gave me to the real query but I can't get it to work.
Here is the actual code
PHP Code:
<template name="custom_droplinks" templatetype="template" date="1176624912" username="harmor" version="1.6.0"><![CDATA[<div class="vbmenu_popup" id="adv$dlink[dlc_catid]menu_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr><td class="thead">$dlink[title]</td></tr>
$custom_droplinks_bit
</table>
</div>]]></template>
<template name="custom_droplinks_cat" templatetype="template" date="1176624827" username="harmor" version="1.6.0"><![CDATA[<td id="adv$dlink[dlc_catid]menu" class="vbmenu_control">
<a href="#">$dlink[title]</a>
<script type="text/javascript">
vbmenu_register("adv$dlink[dlc_catid]menu");
</script>
</td>
]]></template>
<plugin active="1" executionorder="5">
<title>Custom Links</title>
<hookname>global_start</hookname>
<phpcode><![CDATA[
$last_cat = '0';
$getdroplinks_cat = $db->query_read("SELECT
droplink_cat.catid as dlc_catid,
droplink.catid as dl_catid,
droplink.new_window,
droplink.link_perms,
droplink.name,
droplink.image,
droplink.url,
droplink.alt,
droplink.number,
droplink_cat.title,
droplink_cat.permissions,
droplink_cat.display
FROM " . TABLE_PREFIX . "custom_droplinks_cat AS droplink_cat
LEFT JOIN " . TABLE_PREFIX . "custom_droplinks AS droplink ON (droplink_cat.catid=droplink.catid)
ORDER BY dl_catid ASC ");
while($dlink = $db->fetch_array($getdroplinks_cat))
{
eval('$custom_droplinks_cat .= "' . fetch_template('custom_droplinks_cat') . '";');
$custom_droplinks_bit .= "<tr><td class='vbmenu_option'>$img<a href='".$dlink['url']."' target='$new' title='".$dlink['alt']."'>".$dlink['name']."</a></td></tr>";
eval('$custom_droplinks = "' . fetch_template('custom_droplinks') . '";');
}