Andrew
Andrew

Reputation: 969

Dynamically changing page titles w/ PHP & MySQL

The way my website is set up, every page includes header.php to connect to our mysql database, and set up the header/boring html stuff (head, styles, scripts, etc).

After header.php is included, each page uses different queries to access the information that that page needs. My problem is that the page title (<title></title>) depends on the information in the database, and by the time I get that information the title tags are already set in header.php.

Is there any way I could get around this?

Upvotes: 1

Views: 930

Answers (1)

Toby Allen
Toby Allen

Reputation: 11213

Using a templating engine such as smarty (and others) is one solution, then you can wait until you have all your data loaded before rendering your header.

A templating engine is the correct way to do what you want to do.

Upvotes: 4

Related Questions