Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2007, 09:48 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Category Tree

I have this table with the following structure.

id
category
catimage
catimagebig
parent
description

I am trying to get it to display like

Category
parent1, parent2, parent3

I tried many combinations and I am not simply able to achieve it. The latest I have is all messed up

PHP Code:
$getcats=$db->query_read("SELECT  * from " TABLE_PREFIX "table where parent='0'
ORDER BY category ASC"
);
while (
$cats=$db->fetch_array($getcats))
{
$catmain=$cats['category'];
$catid=$cats['id'];
if(
$cats['catimage']!='')
{
$catimage="<img style=\"padding-right:4px;\" align=\"left\" border=\"0\" alt=\"$catmain\" src=\"images/caticons/".$cats['catimage']."\" />";
} else {
$catimage="";
$allcats[]=$getcats['id'];
}
 
foreach(
$allcats as $allcat){
$sublimit=$vbulletin->options['ypsublimit'];
 
$getsubcats=$db->query_read("SELECT  * from " TABLE_PREFIX "table where parent > 0 ORDER BY category ASC LIMIT $sublimit");
while (
$subcat=$db->fetch_array($getsubcats))
{
$mysubcats=$subcat['category'];
eval(
'$subcats .= "' fetch_template('pagessubcats') . '";');
}
}
eval(
'$html .= "' fetch_template('pagesmain') . '";');

Please what am I doing wrong?
Reply With Quote
  #2  
Old 02-21-2007, 01:33 AM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am going a bit insane here. Look at the first 2 categories, then look at the duplicates for sports

PHP Code:
if ($_REQUEST['do']=='main')
{

$getcats=$db->query_read("SELECT  * from " TABLE_PREFIX "ypcats
ORDER BY category ASC"
);
 
$rcount=1;
 
$rpertr$vbulletin->options['ypmaincolumns'];
 
$rrows $db->num_rows($getcats);
while (
$mycats=$db->fetch_array($getcats))
{
if(
$mycats['parent']=='0'){
$catmain=$mycats['category'];
$catid=$mycats['id'];
if(
$mycats['catimage']!='')
{
$catimage="<img style=\"padding-right:4px;\" align=\"left\" border=\"0\" alt=\"".$catmain."\" 
src=\"images/yellowpages/caticons/"
.$mycats['catimage']."\" />";
} else {
$catimage="";
}
}
//#################################
$subcats=null;
$getsubcats=$db->query_read("SELECT  * from " TABLE_PREFIX "ypcats where parent=$catid
ORDER BY category ASC"
);

while (
$getsub=$db->fetch_array($getsubcats))
{
if(
$getsub['parent'] >='0'){
$mysubcats=$getsub['category'];
$mysubid=$getsub['id'];

eval(
'$subcats .= "' fetch_template('haitiwebs_yellowpagessubcats') . '";');
}
 
eval(
'$html .= "' fetch_template('haitiwebs_yellowpagesmain') . '";');

 if (
$rcount == $rpertr && $rcount != $rrows)
  
$rcount 0;
  
$rcount++; 
}   while (
$rcount != && $rcount $rpertr)
    {
     eval(
'$html .= "' fetch_template('haitiwebs_yellowpagesmain') . '";');
        
$rcount++;
    } 
Attached Images
File Type: jpg yp.jpg (41.8 KB, 0 views)
Reply With Quote
  #3  
Old 02-21-2007, 02:24 AM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

phew!!! I think I got it! Freakin loop!!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:11 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03589 seconds
  • Memory Usage 2,223KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (1)postbit_attachment
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete