Jump to content

Display dynamic text in Title


jbuck20

Recommended Posts

I have created an image gallery and I want to display dynamic data in the <title> tag of the header.  Currently the $title sets to the first record in the array and stays locked.  When a new image is selected the $title in <title> does not change.  The code is below.  Thanks for the help.

 

1 $id = $row['id'];

2 $title = $row['title'];

3 $dimensions = $row['dimensions'];

4 $media = $row['media'];

5 //get the dimesions of the main image

6 $imageSize = getimagesize('images_art/'.$image);

7 $thumbSize = getimagesize('images_art/thumbs/'.$image);

8 ?>

9 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

10 <html xmlns="http://www.w3.org/1999/xhtml">

11 <head>

12 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

13 <title><?php  if (isset($id)) {echo "{$title}";} ?>

14 </title>

15 </head>

Link to comment
https://forums.phpfreaks.com/topic/184298-display-dynamic-text-in-title/
Share on other sites

To change the title without a page reload (if it can be done) you will need to use Javascript. In order for the title to change you have to do a page reload with just PHP/HTML as the PHP is done on the server side and all HTML does is display data. Javascript can manipulate HTML on the client side.

 

So yea, if it can be done you will have to use Javascript or force a page reload each time someone selects a new image.

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.