bgbs Posted October 27, 2009 Share Posted October 27, 2009 I'm using inc.header.php that I include in every page. Is this a proper procedure? The inc.header.php contains all my header information, because of that I can't just create different <head> information on every page since it is already included in inc.header.php. But, how do I make it unique? Should I just not include <head> info in inc.header.php and instead include it in every page? But that solution is too lengthy to implement if you have 50 pages. Or is there a dynamic way of generating unique <head> meta information from page description and title. Please let me know Ben Quote Link to comment https://forums.phpfreaks.com/topic/179234-how-do-i-create-unique-meta-information-in-for-each-page/ Share on other sites More sharing options...
mrMarcus Posted October 27, 2009 Share Posted October 27, 2009 usually you would draw data/information from a database for such a thing. have a field like 'meta_title' for each record, and have a unique title stored in that field. Quote Link to comment https://forums.phpfreaks.com/topic/179234-how-do-i-create-unique-meta-information-in-for-each-page/#findComment-945642 Share on other sites More sharing options...
bgbs Posted October 27, 2009 Author Share Posted October 27, 2009 usually you would draw data/information from a database for such a thing. have a field like 'meta_title' for each record, and have a unique title stored in that field. \ I guess that would be an expert way of doing it, but is there a newbie way? Quote Link to comment https://forums.phpfreaks.com/topic/179234-how-do-i-create-unique-meta-information-in-for-each-page/#findComment-945648 Share on other sites More sharing options...
mikesta707 Posted October 27, 2009 Share Posted October 27, 2009 whats so hard about drawing data from a database? just a simple select statement. what does your inc.header.php page look like right now? Instead of hard coding the meta data in you could just get it from a data base, and echo variables that hold the meta data Quote Link to comment https://forums.phpfreaks.com/topic/179234-how-do-i-create-unique-meta-information-in-for-each-page/#findComment-945651 Share on other sites More sharing options...
bgbs Posted October 27, 2009 Author Share Posted October 27, 2009 You see, I have very limited php skills, I'm a designer by trade and coding doesn't come natural with me. Maybe you can help me modify this script that was already made by a coder sometime ago. Ok, so this script generates title for the ad page. <h1><?PHP $ad = ""; $ad = $db->get_row("SELECT user_id,title,type,body,date_update,image,uid FROM ad WHERE id = '$adid'"); // $subject = htmlspecialchars($ad->title, ENT_QUOTES); // $subject = urlencode($ad->title); $subject = str_replace('\'', '', $ad->title); $subject = str_replace('"', '', $subject); $subject = str_replace('&', 'and', $subject); $ad->user_id; $poster = $db->get_row("SELECT id,first_name,last_name,email_address,phone_office,phone_ext,phone_mobile,co_name,co_name_url,co_address3,co_city,co_state,co_country,url FROM user WHERE id = '$ad->user_id'"); echo $ad->title; ?> </h1> The echo $ad->title; is also used like this to generate title for the page <head> <title><?PHP echo $ad->title; ?></title> </head> This code works, but the problem is, the coder included that <head> information in the same page file. I would it to be included in the inc.header.php. But when I do, it doesnt render the page title. The code is meant to work only where <head> is found in the same file. How can I fix this issue? Quote Link to comment https://forums.phpfreaks.com/topic/179234-how-do-i-create-unique-meta-information-in-for-each-page/#findComment-945676 Share on other sites More sharing options...
bgbs Posted October 27, 2009 Author Share Posted October 27, 2009 I guess I figured it out, I had reshuffle some things Quote Link to comment https://forums.phpfreaks.com/topic/179234-how-do-i-create-unique-meta-information-in-for-each-page/#findComment-945711 Share on other sites More sharing options...
mrMarcus Posted October 27, 2009 Share Posted October 27, 2009 usually you would draw data/information from a database for such a thing. have a field like 'meta_title' for each record, and have a unique title stored in that field. \ I guess that would be an expert way of doing it, but is there a newbie way? for the record, i'm hardly an expert. it's really not a difficult process as mike stated. this is a help forum, and people here are willing to help get other people going on such tasks. once you get going with databases, you're going to wonder how you ever did without. seems you figured it out you say .. don't hesitate to post here though, just make sure you state very clearly any issues you're having with your current code, any error(s) that might also be associated, and as detailed a description (without being too lengthy), about what caused the error(s) and/or what you are trying to achieve. keep in mind though, this is a help forum, not a do for you forum. Quote Link to comment https://forums.phpfreaks.com/topic/179234-how-do-i-create-unique-meta-information-in-for-each-page/#findComment-945717 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.