adipalmer123 Posted March 21, 2011 Share Posted March 21, 2011 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 Quote Link to comment Share on other sites More sharing options...
adamlacombe Posted March 21, 2011 Share Posted March 21, 2011 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 Quote Link to comment Share on other sites More sharing options...
adipalmer123 Posted March 21, 2011 Author Share Posted March 21, 2011 Hi Thanks Adam I thought of something like this but say if i've got 8 pages, how would i differenciate each variable with the relevent page title, meta description etc?? Cheers Adi Quote Link to comment Share on other sites More sharing options...
adamlacombe Posted March 21, 2011 Share Posted March 21, 2011 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'); Quote Link to comment Share on other sites More sharing options...
adipalmer123 Posted March 21, 2011 Author Share Posted March 21, 2011 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 Quote Link to comment Share on other sites More sharing options...
adamlacombe Posted March 21, 2011 Share Posted March 21, 2011 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? Quote Link to comment Share on other sites More sharing options...
adipalmer123 Posted March 21, 2011 Author Share Posted March 21, 2011 Yes I do Thats great thanks Much appriciated. Just another quick question - is it good etiqute to use includes? Adi Quote Link to comment Share on other sites More sharing options...
adamlacombe Posted March 21, 2011 Share Posted March 21, 2011 sure, I use them when needed. I mean too much of anything isn't good but if there is a need then its fine Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.