How would I write the conditional statement to get different meta tags dynamically based on page_name.

I am sure the syntax is nowhere near correct but I am looking for something like this:

if page_name="home";
  echo 'Meta1';

else_if page_name="about_us";
  echo 'Meta2";

else 'Tell Donnie to go back to html and css';

Darn good thing there is a newbie forum, cuts way down on the embarrassment when you lay out a conditional statement that is that scary and sad.

I thank you again in advance for your help... and of course I thank the Lord for giving you the patience of the Nestle Quick Bunny with somebody thats head is as thick as mine seems to be. I could have sworn I was smart before I began to try to learn php. he he.....

You guys are the most awesome php Gods in all the land.

Thanks,
Donnie

    So wait, are you actually looking for an SQL query? I would simply make a table that holds your page name and your meta keywords. Basically looking like:

    pageName VARCHAR(255)
    metaKey VARCHAR(255)
    metaDesc TEXT

    From there, create a SQL query that takes the page name, checks the database, and if those keywords exist, spit them out on the page.

    Is this what you are looking for, or am I confused?

      actually, I can't exactly do that. I have to do it with a query.

      The reason for this is because I give the website owner the ability to edit their own page_content, and want to give them access to edit their meta tags, but not the layout (header, navigation, footer, copyright, etc...) and I am doing this with _GET values. so I need to lay my index out this way:

      <?php
      require_once( 'globals.php' );
      require_once( 'layout.php');
      getMeta();
      getHeader();
      getNavigation();
      getPage();
      getFooter();
      getCopyright();
      ?>
      

      so as you see the reason one table won't work is that I need to get meta then I have the header and navigation then the page content.

      Also I have 2 separate tables now. one table named content, the other named layout. User editable page content is in the content table, the non editable areas are in the layout table. Now I need to add a third table for meta so it can call that editable area, then non editable, then editable again, then non editable again to the end of the page.

      Okay, I am confusing myself now.

      What I need is how to write the conditional statement with the sql query that will select the proper table from the meta database table based on the page name.

      Thanks,
      Donnie

        I'm also a newbie. But I been working with my metas also. what I did was something like this.

        metas.php

        <?php
        $meta1 = "meta1 here";
        $meta2 = "meta2 here";
        $meta3 = "meta3 here";
        ?>
        

        All you have to do is include the metas.php file

        <?php include "metas.php"; ?>
        

        and then call the variable like so

        <meta name="keywords" content="<?php echo "$meta1"; ?>" >
        

        No database table needed

        and then you can give the user control to change the metas with something like this http://phpbuilder.com/board/showthread.php?t=10353415

        I hope this help but remember make sure this is a better practice. Personally I think is faster.

          Write a Reply...