Jump to content

Recommended Posts

Hey guys im in the middle of customizing a php cms app to fit my site...im basically reusing some of its code.

im currently working on the nav which is an accordion spry i will be using php to get categories and subcategories and echoing them so as to create the accordion.

 

 

the subcategories should appear under its category. In the database there are one category for many subcats and one subcat for mutiple products...so tbl_subcat has its own id plus the cat_id as the foreign key.

the origianl nav script echoed <li></li> for only categories..i adopted it for divs

here is the page http://vaughntucker.com/exflowers/about.php?

 

 

The problem im having is loading all the subcats under each category it only does one row and it repeats the same subcat for the rest of the categories so i know my php

logic is off but im stumped...

 

here is the entire code http://vaughntucker.com/exflowers/about.txt

 

This is what the accordion with the do while function looks like

<?php

      do {

if($row_get_subcats['subcat_id']==$current_subcat){

$link_look='class="selectedPage"';

 

}else{

$link_look='';

 

}

?>

<div class="AccordionPanel">

<div class="AccordionPanelTab"><a href="about.php?cat=<?php echo $row_get_cats['cat_id']; ?>"

>

<?php echo $row_get_cats['cat_name']; ?></a></div>

 

<div class="AccordionPanelContent"><a href="about.php?subcat=<?php echo $row_get_subcats['subcat_id']; ?>&cat=<?php echo $row_get_cats['cat_id']; ?>"

<?php echo $link_look;?>>

<?php

 

echo $row_get_subcats['subcat_name'];?></a></div></div>

 

  <?php  }while ($row_get_cats = mysql_fetch_assoc($get_cats));  ?>

 

 

 

 

 

i was told i need to use a where clause in my sql statement but i have problems implementing that too...

here are my sql statements...

 

//get all cats for side nav// //

mysql_select_db($database, $makeconnection);

$sql_get_cats = "SELECT * FROM tbl_cat ORDER BY cat_id ASC";

$get_cats = mysql_query($sql_get_cats, $makeconnection) or die(mysql_error());

$row_get_cats = mysql_fetch_assoc($get_cats);

$totalRows_get_cats = mysql_num_rows($get_cats);

 

 

//get all subcats for side nav//ORDER BY catsub_id ASC  ASC*/

mysql_select_db($database, $makeconnection);

$sql_get_subcats = "SELECT * FROM tbl_subcat ";

$get_subcats = mysql_query($sql_get_subcats, $makeconnection) or die(mysql_error());

$row_get_subcats = mysql_fetch_assoc($get_subcats);

$totalRows_get_subcats = mysql_num_rows($get_subcats);

 

///Sub category heading

$current_subcat="Home";

if(isset($current_subcatNum)){

$sql_get_page="SELECT subcat_name FROM tbl_subcat WHERE  subcat_id='$current_subcatNum'";

$get_subcat_name = mysql_query($sql_get_page, $makeconnection) or die(mysql_error());

$row_get_subcat_name = mysql_fetch_assoc($get_subcat_name);

$current_subcat=$row_get_subcat_name['subcat_name'];

}

 

///find page title

$page_title="Home";

if(isset($current_cat)){

$sql_get_page="SELECT cat_name FROM tbl_cat WHERE cat_id='$current_cat'";

$get_title = mysql_query($sql_get_page, $makeconnection) or die(mysql_error());

$row_get_title = mysql_fetch_assoc($get_title);

$page_title=$row_get_title['cat_name'];

}

 

i'll appreciate any help thanks....

 

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.