[PHP] Dynamic Breadcrumb for tracing navigation

Hello, This is the code for Breadcrumb class.

class Breadcrumb

    public function getBreadcrumb($code){

        $bc = [];

        while( $code != '1' ){

            $sql = "SELECT PAR,NAME,CODE FROM global_tbl WHERE CODE =" . $code;
            $instance = db_query($sql);

            $row = mysqli_fetch_array($instance);

            $bc[] = [
                'parent' => $row['PAR'],
                'code' => $row['CODE'],
                'name' => $row['NAME']

            $code = $row['PAR'];


        return $bc;



$bc = new Breadcrumb();

$breadcrumb = $bc->getBreadcrumb($_GET['parentCode']);

// this is for using this breadcrumb though html.
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">
        <ol class="breadcrumb">
                <i class="fa fa-dashboard"></i>  <a href="index.html">Dashboard</a>


            foreach($breadcrumb as $bc):

            <li class="">
                <a href="entryDataGlobalTable.php?parentCode=<?= $bc['code'] ?>">
                    <i class="fa fa-edit"></i> <?= $bc['name'] ?>
            <?php endforeach; ?>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s