Return to Snippet

Revision: 14041
at May 16, 2009 15:27 by jiggyhat


Initial Code
echo '<div class="dynamic_nav_head">Navigation</div><div class="dynamic_nav">';  // on less echo
        include('data.php');
        $tables = mysql_list_tables($database);
          while (list($table) = mysql_fetch_row($tables)) {     
                    if($table!='includes'){
                          $ucTable= ucwords($table); // just one function call
                           //  just one echo;
                           // you where also using quotes and double quotes backwards

                           echo '<div class="cat">'.$ucTable.'</div><div class="cat_item"><a href="?page=read&section='.$table.'">View ' .$ucTable.'</a></div><div class="cat_item"><a href="?page=add&section='.$table.'">Add New '. $ucTable .'</a></div>';
                    }  // End If not in Includes.
          } // End While
      echo '</div>';

Initial URL
http://www.onedef.com

Initial Description
This will create a Navigation from a MySQL database table names.  It removes the table name "includes" by default so you can see how to remove any certain tables you wish to not use as a site section.   Just plug in your MySQL database details and connection info into data.php and you should be great to go.

Initial Title
Dynamic Navigation From Database Table Names

Initial Tags
css, mysql, database, php, navigation

Initial Language
PHP