Go Back   kirupaForum > Development > Server-Side (PHP, SQL, ASP.NET, etc.)

Reply
 
Thread Tools Display Modes
Old 11-19-2009, 03:50 PM   #1
drummer392
Brandon R. Ray
 
drummer392's Avatar
Fla Box Subpages not showing up

Hi there,

I have built a menu using CSS, PHP, and javascript. Here is the PHP code below. I am trying to figure out why the sub-sub pages won't show up. The sub category shows up, but not the pages that belong to it.

If I exchange the WHERE subid={$subcat[id]} and make it WHERE subid=1, then it shows up. But otherwise, it isn't recognizing the "id" of the sub category.

PHP Code:
    # Connect to the database 

// Get the categories 
$cat_result mysql_query('SELECT catid, category FROM category;'); 

// Loop through the categories 
while ($category mysql_fetch_assoc($cat_result)) 

    echo 
"<li><a href='javascript:blankfunction()'>{$category[category]}</a><ul>"

    
// Category Pages Loop    
    
$page_result mysql_query("SELECT id, title FROM pages WHERE catid={$category[catid]};"); 
     
    while (
$page mysql_fetch_assoc($page_result)) 
    { 
        echo 
"<li><a href='sidepage.php?id={$page[id]}'>{$page[title]}</a></li>";
    }
    
//Sub-category loop
    
$subcat_result mysql_query("SELECT id, catid, subcat FROM subcat WHERE catid={$category[catid]};");

    while (
$subcat mysql_fetch_assoc($subcat_result))  
    {  
    echo 
"<li><a href='javascript:blankfunction()'>{$subcat[subcat]}</a><ul>";  
    } 
    
// Sub-category page loop 
    
$subpage_result mysql_query("SELECT id, subid, title FROM subpages WHERE subid={$subcat[id]};");  
      
    while (
$subpage mysql_fetch_assoc($subpage_result))  
    {  
        echo 
"<li><a href='sidepage.php?id={$subpage[id]}'>{$subpage[title]}</a></li>"

    }  
    echo 
"</ul></li>"


Thanks way in advance!

Last edited by drummer392; 11-20-2009 at 08:35 AM..
drummer392 is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-20-2009, 01:25 AM   #2
actionAction
humanBeing._beard=true;
 
actionAction's Avatar
Try this:

PHP Code:
while ($subcat mysql_fetch_assoc($subcat_result)) 
    { 
        
$subcategory $subcat['subcat'];
    echo 
"<li><a href=\"javascript:blankfunction()\">$subcategory</a><ul>"
    }
    
// Sub-category page loop
    
$subpage_result mysql_query("SELECT id, subid, title FROM subpages WHERE subid=" subcat['id']); 
     
    while (
$subpage mysql_fetch_assoc($subpage_result)) 
    { 
        
$id $subpage['id'];
        
$title $subpage['title'];
        echo 
"<li><a href=\"sidepage.php?id=$id\">$title</a></li>";

    } 
    echo 
"</ul></li>"

__________________
help = (!(poster.do_my_homework || poster.not_trying )) ? yes : no;
actionAction is offline   Reply With Quote
Old 11-20-2009, 08:35 AM   #3
drummer392
Brandon R. Ray
 
drummer392's Avatar
hmmm...that didn't change anything.

Let me give you the code for the whole menu. I just gave you the sub-category parts. Maybe that will help:

(updated in 1st post as well)

PHP Code:
# Connect to the database 

// Get the categories 
$cat_result mysql_query('SELECT catid, category FROM category;'); 

// Loop through the categories 
while ($category mysql_fetch_assoc($cat_result)) 

    echo 
"<li><a href='javascript:blankfunction()'>{$category[category]}</a><ul>"

    
// Category Pages Loop    
    
$page_result mysql_query("SELECT id, title FROM pages WHERE catid={$category[catid]};"); 
     
    while (
$page mysql_fetch_assoc($page_result)) 
    { 
        echo 
"<li><a href='sidepage.php?id={$page[id]}'>{$page[title]}</a></li>";
    }
    
//Sub-category loop
    
$subcat_result mysql_query("SELECT id, catid, subcat FROM subcat WHERE catid={$category[catid]};");

    while (
$subcat mysql_fetch_assoc($subcat_result))  
    {  
    echo 
"<li><a href='javascript:blankfunction()'>{$subcat[subcat]}</a><ul>";  
    } 
    
// Sub-category page loop 
    
$subpage_result mysql_query("SELECT id, subid, title FROM subpages WHERE subid={$subcat[id]};");  
      
    while (
$subpage mysql_fetch_assoc($subpage_result))  
    {  
        echo 
"<li><a href='sidepage.php?id={$subpage[id]}'>{$subpage[title]}</a></li>"

    }  
    echo 
"</ul></li>"

drummer392 is offline   Reply With Quote
Old 11-20-2009, 05:46 PM   #4
drummer392
Brandon R. Ray
 
drummer392's Avatar
got it to work!
drummer392 is offline   Reply With Quote
Old 11-20-2009, 06:09 PM   #5
actionAction
humanBeing._beard=true;
 
actionAction's Avatar
How? What did you change?

__________________
help = (!(poster.do_my_homework || poster.not_trying )) ? yes : no;
actionAction is offline   Reply With Quote
Old 11-20-2009, 06:12 PM   #6
drummer392
Brandon R. Ray
 
drummer392's Avatar
Well, I here is the new code.

PHP Code:
while ($subcat mysql_fetch_assoc($subcat_result)) 
    { 
    
$subcategory $subcat['subcat'];
    
$sid $subcat['id'];
    echo 
"<li><a href=\"javascript:blankfunction()\">$subcategory</a><ul>"
    }
    
// Sub-category page loop
    
$subpage_result mysql_query("SELECT id, subid, title FROM subpages WHERE subid={$sid}"); 
     
    while (
$subpage mysql_fetch_assoc($subpage_result)) 
    { 
        
$id $subpage['id'];
        
$sptitle $subpage['title'];
        echo 
"<li><a href=\"sidepage.php?id=$id\">$sptitle</a></li>";

    } 
    echo 
"</ul></li>";  

drummer392 is offline   Reply With Quote
Old 11-20-2009, 06:32 PM   #7
actionAction
humanBeing._beard=true;
 
actionAction's Avatar
I think it was a rogue semicolon here:
$subpage_result = mysql_query("SELECT id, subid, title FROM subpages WHERE subid={$subcat[id]};");

__________________
help = (!(poster.do_my_homework || poster.not_trying )) ? yes : no;
actionAction is offline   Reply With Quote
Old 11-21-2009, 02:18 AM   #8
drummer392
Brandon R. Ray
 
drummer392's Avatar
yeah. I caught some of the semicolon/quote errors. I also added $sid = $subcat[id]; and put $sid in place of that code.
drummer392 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 -4. The time now is 06:12 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com