Jump to content

Different titles in included php


Sound

Recommended Posts

I run a website were you could read a lot of reviews. Every review is included into the index.php via;

 

<?
}
elseif ($_GET['page'] == "stormwarriorheadingnorthereview")
{
?>
<? include("writings/stormwarrior_heading_northe_review.txt") ?>

 

 

I simply want the "Stormwarrior" review (and all the other reviews) to get a different title than the rest of the site. What should I do?

Link to comment
https://forums.phpfreaks.com/topic/122234-different-titles-in-included-php/
Share on other sites

By title, you mean the html title tag? If so you can simply:

 

<?php
<head>
<title><?php echo $_GET['somereviewpage']; ?></title>
</head>
?>

 

That isn't quite useful though as you just get some ugly titles. The best way to do this is to store your reviews in a database and have a title field. You can add all those text files of yours in the db quite easily (be it manually or automatically).

 

The db table can be something like this:

review_id   |   content   |   title   |   author   |   date

 

Hope it helps.

Your site went white? Strange. You can just add that code in the title tag:

 

<title>
<?php
if(isset($_GET['page'])){
     echo $_GET['page'];
} else{
     echo 'This is home';
}
?>
</title>

 

Something like that. The title tag should be inside the < head > tag. As i said, the best approach to this should be using a MySQL database.

Ok we are going on a dead-end. I'm not asking you to be a php expert, but at least try asking the right question.

 

What do you mean by title, i asked it since the first post. Is it:

Very nice movie

Im writing a review about a movie and my review title is "Very nice movie".
Read my review as it is very long...or isn't it. Ok i'm done.

 

If you mean a < title > tag, which is the title that shows in the browser's top left corner, then use the code i suggested. The "echo 'This is home'" part will display the title in every page where the 'page' url variable (the review name) is not set. What do you want to know more?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.