SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Improving Breadcrumbs Navigation Script

    Happy new year to all,

    I been working on my ecommerce system over the break and added my breadcrumb navigation, i'm now looking for ways to reduce the size of the code in this script, could anyone offer and advice or ways to reduce this code:

    Code:
    // Breadcrumb Navigation
    $breadcrumbnav = "> ".$category_name." ";
    
    for ($x = 1; $x < 10; $x++) {
      // If $x is odd, break out
      $bread_id = $category_id;
      if ($parent_id != "") {
        $bread_id = $parent_id;
      }
      $sql = "SELECT parent_id FROM ".$siteid."_categories WHERE category_id='$bread_id'";
      $query = mysql_query($sql, $dbConn);
      $row = mysql_fetch_array($query, MYSQL_ASSOC);
      $parent_id = $row['parent_id'];
      if ($parent_id == 0) {
        break;
      } else {
        $sql = "SELECT category_name FROM ".$siteid."_categories WHERE category_id='$parent_id'";
    	$query = mysql_query($sql, $dbConn);
    	$row = mysql_fetch_array($query, MYSQL_ASSOC);
        $cat_name = $row['category_name'];
        $breadcrumbnav = "> <a href='catalog.php?a=".$parent_id."'>".$cat_name."</a> ".$breadcrumbnav." ";
      }
    }
    It is different to ways i seen breadcrumbs done before, but i have decided my database to look up products and categories in a different way to normal.

    Thank you in advance for any help.

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this a good place to ask this question, or where would be better?

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bump, anyone any advice on this?

    I would like to reduce the lines of code as much as possible


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •