vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with queries (https://vborg.vbsupport.ru/showthread.php?t=120524)

harmor19 07-07-2006 02:30 AM

Help with queries
 
I have two table; one is for categories, the other for links.
What I want to do is show the category then show the relative links.
Basically I would like to work like categories and forums.
You have the "News And Announcements" category then follows the forums.

Paul M 07-07-2006 04:38 AM

So what exactly is your question ?

harmor19 07-07-2006 05:06 AM

1 Attachment(s)
I am upgrading my "Custom Navbar Links" hack and I would like to add seperators.

I have two table; custom_links_cat and custom_droplinks

custom_links_cat
  • catid
  • title
  • link_perms

custom_droplinks
  • linkid
  • catid
  • url
  • name
  • ....

My hack is like "Quick Links" but user defined. Hopefully the image will explain what I want.

harmor19 07-07-2006 09:10 PM

I need help. I got it to do what I wanted but it only gets the first catid it comes across instead of all of them.

PHP Code:

$getcats $db->query_read("SELECT * FROM " TABLE_PREFIX "custom_links_cat");
     while(
$cat $db->fetch_array($getcats))
     {
       
        
$getdroplinks $db->query_read("SELECT * FROM " TABLE_PREFIX "custom_droplinks WHERE catid='$cat[catid]' ");
        while(
$dlink $db->fetch_array($getdroplinks))
        {    
           
$custom_droplinks .= "<tr><td class='thead'>".$cat['title']."</td></tr>
                     <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') . '";');
        }
      } 


harmor19 07-11-2006 09:10 PM

Please help.

harmor19 07-12-2006 04:40 AM

1 Attachment(s)
what's wrong with this code
PHP Code:

getdroplinks $db->query_read("SELECT * FROM " TABLE_PREFIX "custom_links_cat clc 
    LEFT JOIN " 
TABLE_PREFIX "custom_droplinks cdl ON (clc.catid=cdl.catid) 
    WHERE clc.catid=cdl.catid ORDER BY clc.catid ASC"
);

    while(
$dlink $db->fetch_array($getdroplinks))
    {    
       if(
$dlink['new_window'] == 1)
       {
         
$new "_blank";
        }
        else
        {
         
$new "";
        }
        
        if(!empty(
$dlink['image']))
        {
          
$img "<img src='".$dlink['image']."' width='16' height='16' />";
        }
        else
        {
          
$img "";
        }
        
        
$dlink['link_perms'] = explode(","$dlink['link_perms']);

if(
in_array($vbulletin->userinfo['usergroupid'], $dlink['link_perms']) )

    
$custom_droplinks .= "<tr><td class='thead'>".$dlink['title']."</td></tr>    
    <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') . '";');
    } 

Screenshot of what it's producing below

Paul M 07-12-2006 07:13 AM

Everytime you loop round (for each record) the code adds the header and the link, there is nothing to check if the header is the same as the previous record.

harmor19 07-12-2006 07:21 AM

So how would I check it?

harmor19 07-17-2006 12:09 AM

I finally got it.
If you people didn't help because you thought I wasn't trying then you all wrong

PHP Code:

$getdroplinks $db->query_read("SELECT * FROM " TABLE_PREFIX "custom_links_cat clc
LEFT JOIN " 
TABLE_PREFIX "custom_droplinks cdl ON (clc.catid=cdl.catid) "); 

$prev_cat '0'

while(
$dlink $db->fetch_array($getdroplinks))
{
    
       if(
$dlink['new_window'] == 1)
       {
         
$new "_blank";
        }
        else
        {
         
$new "";
        }
        
        if(!empty(
$dlink['image']))
        {
          
$img "<img src='".$dlink['image']."' width='16' height='16' />";
        }
        else
        {
          
$img "";
        }
        
        if(
$dlink['catid'] != $prev_cat)
        {
            
$custom_droplinks .= "<tr><td class='thead'>".$dlink['title']."</td></tr>";
        }
        
        
$dlink['link_perms'] = explode(","$dlink['link_perms']);


            if(
in_array($vbulletin->userinfo['usergroupid'], $dlink['link_perms']) )
            { 
                
$custom_droplinks .= "$header
                <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') . '";');
        
        
$prev_cat $dlink['catid']; 
    } 


ShadyB 01-30-2007 09:09 PM

Can I rename the title on the navbar saying Extras?


All times are GMT. The time now is 12:03 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01077 seconds
  • Memory Usage 1,767KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete