dynamic breadcrum in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunil rawat
    New Member
    • Jun 2011
    • 3

    dynamic breadcrum in php

    hi i have a table in database having Module name and module id.and another table having section name crrosponding to each module.now i want to display the bread crums on my page in php.how can i do this.
    i am using Url in My application as follows.MyFolde r/crm.php?mod=3&s ectionID=22&tas k=queueCont

    according to this url i have to create a dynamic class for breadcrums for my application.ple ase help me..
  • nathj
    Recognized Expert Contributor
    • May 2007
    • 937

    #2
    If that URL has all the information in it to retrieve the breadcrumb from the database then it should be a simple task to query the DB to get the page names/titles and then use a horizontal list to display them.

    I would recommend developing a small php function that would do jsut that - take the parameters from the url, query the datbase and return the breadcrumb string for display. This function could then be used whereever you need to display the breadcrumb.

    Have a play around with that basic flow and if you get stuck with anything in particular post back here including a code snippet.

    Cheers
    nathj

    Comment

    • sunil rawat
      New Member
      • Jun 2011
      • 3

      #3
      how to create this function please provide some demo of this.i am confussed

      Comment

      • nathj
        Recognized Expert Contributor
        • May 2007
        • 937

        #4
        Hi,

        I am happy to help you with your own code, I am not going to simlpy provide the code for you. Here is a rough plan of what should happen:

        1. pass the variables from the URL query string to a function as parameters.

        2. make a database connection

        3. query the database using the parameters to get the page and section titles

        4. build a string that is the breadcrumb

        5. return the string

        6. echo the value to the screen.

        Now it's over to you, you have a go at developing that. If you get stuck with any specific code post back the code you have and we will do our best to help you out.

        Cheers
        nathj

        Comment

        • sunil rawat
          New Member
          • Jun 2011
          • 3

          #5
          <?php
          require_once($_ SERVER['DOCUMENT_ROOT'].'/bamko3/includes/config.php');
          class BreadCRM
          {

          function getBreadCrum($m odel_id,$sectio n_id)
          {
          $sql="select moduleName from bmk3_modules where moduleId=$model _id"
          $breadCrum = <<<PATH

          <a href="crm.php?m od_id=$model_id ">$row['moduleName']</a>
          PATH;
          $breadCrum .= " &raquo; ";
          $sql="select sectionName,par entSection from bmk3_sections where sectionId=$sect ion_id"
          $breadCrum .="<a href='crm.php?m od_id=$model_id &section_id=$se ction_id'>secti on name</a>";
          $parent_id=sect ion parent section from above result

          $sql="select sectionName from bmk3_sections where id=$parent_id"
          $breadCrum .= "<a href='crm.php?m od_id=$model_id &section_id=$se ction_id&task=f etch section name'>section name</a>";
          return $breadCrum;
          }
          }
          ?>

          Comment

          • nathj
            Recognized Expert Contributor
            • May 2007
            • 937

            #6
            Hi Sunil,

            Good to see you have had a crack at this function. DO you have any specific questions about this? If so post back and I'll do my best to answer them for you.

            Cheers
            nathj

            Comment

            Working...