Jump to content

error on nav


ecabrera

Recommended Posts

why do i get a error

 

on

 

<li><a href='#nogo'>$cat['parent']</a></li>

 

echo "
    <div id='navigation'>
<ul id='nav'>
<!-- main item 1 -->
<li class='item1'>
<a href='".strtolower(str_replace(' ', '-', $cat['title'])).".htm'>".str_replace('and', '&', $cat['title'])."</a>
<!-- dropdown or flyout 1 -->

<ul>
<li><a href='#nogo'>$cat['parent']</a></li>
</ul>

</li>
</ul>
</div>
    
    ";

Link to comment
Share on other sites

thanks ok so i want the nav to be like

 

Tech -> Video Games

        -> Computers

      - > Mouses

 

but only some categories have subcategories i want to do an if statement how would i get around that

 

for example

 

if($cat['parent'] > 0){

<ul>

<li><a href='#nogo'>$cat['subparent']</a></li>

</ul>

}else

{

 

}

Link to comment
Share on other sites

ok so how would i do this

 

some categories have subcategory not all of them so i want to make it so that the ones that have subcategory show and the ones that dont dont show

 

the categored are listed by id's for now

 

for example

 

40

34

23

13

53

23

54

34

23

 

the subcategory have a field name parent which has their parents id

 

for example

 

their are three 40's they should be with category 40

 

<?php 

    

    	$sql = "SELECT * FROM ".$sitevar['db']['prefix']."categories WHERE parent = 0 ORDER BY title ASC";

    	$cats = mysql_fetch_all(qrydb($sql));

    	$newsql = "SELECT * FROM ".$sitevar['db']['prefix']."categories WHERE parent > 0 ORDER BY title ASC";

    	$subcats = mysql_fetch_all(qrydb($newsql));


    	foreach ($cats as $cat) 
    	foreach ($subcats as $subcat) 

   
    echo "
    <div id='navigation'>
<ul id='nav'>
<!-- main item 1 -->
<li class='item1'>
<a href='".strtolower(str_replace(' ', '-', $cat['title'])).".htm'>".str_replace('and', '&', $cat['id'])."</a>
<!-- dropdown or flyout 1 -->

<ul>
<li><a href='#nogo'>{$subcat['title']}</a></li>
</ul>

</li>
</ul>
</div>
    
    ";

    ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.