www.webdeveloper.com
Results 1 to 4 of 4

Thread: how retrieve catergory form database for menulist

  1. #1
    Join Date
    Mar 2013
    Posts
    6

    how retrieve catergory form database for menulist

    hi friends
    im basic develop i have i problem ,

    i'm creating the website for upload ads but. i put hard code to the menu.
    i need the menu list should directly come from database.
    i try some code but that are retrieve the data form database
    "but it retrieve automatically link the other page. "

  2. #2
    Join Date
    Feb 2013
    Posts
    80
    I do something like this in php, I don't know if this is what you mean?

    PHP Code:
    function php_navigation($nav_page$page_set) {
            
            
    // Format for php_navigation 
            // <ul>
            //    <li><a href="{link}">Name of Link</a></li>
            // </ul>
            
            
    global $db;        
            
            
    $query "SELECT id, blog_name FROM pages ORDER BY new_blog_date ASC LIMIT 25";
            
            
    $output "<ul>";
            if (
    $result mysqli_query($db$query)) {
                while (
    $page mysqli_fetch_array($result)) {
                    
    $output .= "<li><a href=\"" $nav_page "?page=" urlencode($page["id"]) . "\">";
                   
                   if (
    $page_set == $page['id']) {
                          
    $output .= "<span class=\"selected\" >{$page["blog_name"]}</span>";       
                   } else {
                       
    $output .= "{$page["blog_name"]}";
                   }           
                   
                   
    $output .= "</a></li>";               
                }
                
    /* free result set */
                
    mysqli_free_result($result);            
            }
                    
            
    $output .= "</ul>";        
            
            return 
    $output;
        } 

  3. #3
    Join Date
    Mar 2013
    Posts
    6
    thank you

  4. #4
    Join Date
    Mar 2013
    Posts
    7
    If you're working in ASP.NET, you can put a menu control, and write the query as a stored procedure then stick a datasource on the page and hook them all up. For menus like this that are unlikely to change frequently but appear on all pages, you should also use caching, which can easily be turned on in the control in .net. If you're serving 10,000 pages per day, you don't want to be making 10,000 round trips to the db to get exactly the same data when you can do just one.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles