Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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