I have many dynamic urls generating from mysql server. Justt like: http://www.gadgets4gifts.com http://www.gadgets4gifts.com/products-detail.php?id=34 http://www.gadgets4gifts.com/products.php?product_id=4 I want to add meta tags like title,description and keywords on every URL .Title, description and keyword will be variable of every page. There is only 1 header.php file which is called by every inner page. How can I code this using php ? Please help with correct php code.
You want to add meta tags to a URL? Or to the sites at those URLs? Where is the data for the tags coming from?
Hi Rukbat, Meta tags will be shown in source code of every dynamic page. Data tag coming from txt file. Thanks, Papan
Something like (data in the text file is separated by %): $title='my title'; $handle = fopen($myFile, 'r'); if($handle) { $tags = explode('%', fgets($handle)); echo '<meta name="title" content="'.$title.'"><br />'; echo '<meta name="description" content="'.$tags[0].'"><br />'; echo '<meta name="keyword" content="'.$tags[1].'"><br />'; fclose($handle); } PHP: You could put the code in the 'if' into a while loop, with a value for the page name or number and, if that's the current page, write the meta tags. Then you could have one line in the text file per page. Everyone does this sort of thing differently; do something that's comfortable for you.