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
https://forums.phpfreaks.com/topic/265926-error-on-nav/
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
https://forums.phpfreaks.com/topic/265926-error-on-nav/#findComment-1362610
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
https://forums.phpfreaks.com/topic/265926-error-on-nav/#findComment-1362617
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.