Jump to content

Page Titles and Meta information with includes


adipalmer123

Recommended Posts

Hi all

 

Recently designed a site using includes, but only realised when I'd almost finished the project that because the (e.g.) include("includes/header.html"); had the <head> information (titles, meta description, etc) every single page included the same information (by the way hope this makes sense)

 

A way I thought of getting around this was to store each pages title and meta description in a database or in for example or maybe in a variables.php file. But I'm not sure whether this is the best way.

 

I'm not a PHP expert so simple explainations would be very much appriciated.

 

Look forward to hearing from you all.

 

Adi

Link to comment
Share on other sites

hmm I think I understand what you're saying..

try doing this:

 

$title="this is my title";

$meta_desc="my description";

$meta_key="my, key, words";

include('header.php');

 

then inside header.php place $title $meta_desc and $meta_key in meta tags and title tags

Link to comment
Share on other sites

in every page use this

$title="this is my title";

$meta_desc="my description";

$meta_key="my, key, words";

include('header.php');

 

change what is in them for each page. say its a game page and you want the title to be the game, do this:

 

$query=mysql_query("QUERY HERE");

$row=mysql_fetch_array($query);

$title="$row[title]";

$meta_desc="$row[desc]";

$meta_key="games, free, cool, $row[title]";

include('header.php');

Link to comment
Share on other sites

I understand the first part, but excuse my beginner mentallity :- could you explain the second part a little more?

 

How does the below work?

$query=mysql_query("QUERY HERE");

$row=mysql_fetch_array($query);

$title="$row[title]";

$meta_desc="$row[desc]";

$meta_key="games, free, cool, $row[title]";

include('header.php');

 

Cheers

Link to comment
Share on other sites

Well make up a query say

 

$query = mysql_query("SELECT * FROM `games` WHERE id='$_GET[id]'");

 

so now this is what you want to extract and show so you do the following

 

$row = mysql_fetch_array($query);

 

now you can show any field you want.

 

$row['title'] will show the title of the game. so then you can add the title of the game to the title tags.

 

Understand?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.