Sunday, February 23, 2014

Tute 20 : Make Dynamic Menu - Part Two

Now we make dynamic menu in our home page. So go to the index.php file in notepad++. We make quarry for category table. So write this code in top of page before "$query_run=mysql_query($query);" line :


---------------------------------------------------------------------

$query_cat="SELECT `id`, `category` FROM category";

$query_cat_run=mysql_query($query_cat);

----------------------------------------------------------------------


Now we some edit in <ul></ul> into the " <div id="menu-con"></div>" code. We delate <ul> to </ul> code and write this code :

-------------------------------------------------------------------------------------------

<ul>

      <li><a href="index.php">Home</a></li>

            <?php

                while ($query_cat_row=mysql_fetch_assoc($query_cat_run)){

                  $category=$query_cat_row['category'];

              ?>

        <li><?php echo $category; ?></li>

        <?php }?>

</ul>

-------------------------------------------------------------------------------------------





Then save this file and go to the Google Chrome and refresh the home page. We see our menu item show dynamically.


 

If show problem please cheack the code carefully.

No comments :

Post a Comment