Results 1 to 1 of 1

Thread: PHP&SQL. dynamic meta content.

  1. #1
    epidemic is offline Net Builder
    Join Date
    Jan 2009
    Posts
    112
    Thanks
    2
    Thanked 9 Times in 6 Posts

    PHP&SQL. dynamic meta content.

    I am sure there are more people doing this, for my website I load different meta content trough a database for each and every page.

    Easy and smart!
    index.php
    PHP Code:
    Page_name 'index';
    include_once(
    'PAGE_DATA.php');
    HTML_HEAD($page_title,$meta_description,$meta_keywords
    PAGE_DATA.php
    PHP Code:
    <?php 
        DB_CONNECT 
    ();
        
    // we need to connect to our database;
        
    $result mysql_query("SELECT * FROM pages WHERE Page_name='$Page_name'");
        if (
    $result == false || mysql_num_rows($result) == 0)
        {
            
    header("location:error.php?id=4");
        }
        else
        {

            
    $data mysql_fetch_array($result);
            
    $meta_description $data['meta_content'];
            
    $meta_keywords $data['meta_keywords'];
            
    $page_title $data['Page_title'];
            
        }
        
    DB_DISCONNECT ();
    ?>
    function to print html header
    PHP Code:
    function HTML_HEAD ($page_title,$meta_description,$meta_keywords)
        {
         echo 
    '<head>';
         echo 
    '<LINK REL="SHORTCUT ICON" HREF="favicon.ico"/>';
         echo 
    '<LINK REL="stylesheet" href=style.css" type="text/css" />';
         echo 
    '     <!--[if IE 6]>
                      <link rel="stylesheet" href="ie6.css" type="text/css" title="IE6" />
                    <![endif]--> 
                     
                    
              '
    ;
         echo 
    '<script type="text/javascript" src="jv.js"></script>';
         echo 
    "<title>$page_title</title>";
         
    // Meta data
         
    echo "<meta name='description' content='$meta_description'/>";
         echo 
    "<meta name='keywords' content='$meta_keywords' />";
         echo 
    '<meta name="revisit-after" content="1 days" />';
         echo 
    '</head>';
        } 
    enjoy!
    Last edited by epidemic; 11 January, 2009 at 21:21 PM.

Similar Threads

  1. Dynamic cascading...
    By cranbrook in forum Web Design
    Replies: 0
    Last Post: 5 May, 2011, 11:50 AM
  2. Problem with Dynamic Content Gallery
    By djam in forum Wordpress
    Replies: 1
    Last Post: 28 January, 2011, 11:03 AM
  3. Dynamic website and SEO
    By imported_whitey99 in forum Promoting
    Replies: 1
    Last Post: 14 August, 2009, 14:29 PM
  4. Dynamic website and SEO
    By imported_nikon in forum Promoting
    Replies: 1
    Last Post: 31 May, 2009, 13:04 PM
  5. Looking for a Dynamic Text/Image Replacement
    By Mr.Bill in forum Programming
    Replies: 2
    Last Post: 9 March, 2009, 11:32 AM

Tags for this Thread

Bookmarks

Posting Permissions

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