0

Hi,

I am using PHP & mySql to grab the title and description that I have stored in a table in the DB.

I am trying to dynamically change the <head> <title></title>, as well as <meta name="Description" content="" /> .

I used document.title to change the title. I see the title changing in the browser, but when I click on view source in the browser to see it int he code, the title is empty. How can I also see it in the code?

How do I change the description in the meta tag?

Any ideas?

Thanks

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by Troy III
0

In an PHP Document, all you need to do is embed the php into the html like so

<!doctype HTML>
<html>
<head>
<title><?php echo $title; ?></title>
<meta name="keywords" value="<?php echo $keywords; ?>" />
</head>
<body>
<?php echo $content; ?>
</body>
</html>

You can also use functions in the html that will echo out the database info when they are called. Typically, it's best to store those values to variables, then echo them out in the html.

Edited by codejoust: n/a

0

Hi,

I am using PHP & mySql to grab the title and description that I have stored in a table in the DB.

I am trying to dynamically change the <head> <title></title>, as well as <meta name="Description" content="" /> .

That's lots of coding ahead...

I used document.title to change the title. I see the title changing in the browser, but when I click on view source in the browser to see it int he code, the title is empty. How can I also see it in the code?

this will emulate what you ask in FX

<button onclick="
      var a = document.getElementsByTagName('html')[0].innerHTML;
      document.open(document.location).write(a);
      ">Current Source</button>

This will print the button code also!
But you can run it clean from address bar like this: javascript: var a = document.getElementsByTagName('html')[0].innerHTML; document.open(document.location).write(a); just copy-paste this in FX location bar and hit Enter

How do I change the description in the meta tag?

Any ideas?

replace it with a new one..

0

decided to go with the php and it works.
thanks all :)

Your question was: "I am trying to dynamically change the <head> <title></title>, as well as <meta name="Description" content="" /> .
I used document.title to change the title.?"I see the title changing in the browser, but when I click on view source in the browser to see it int he code, the title is empty. How can I also see it in the code?"

Meaning your question was strictly targeting the dynamicaly changed content and the ability to see its source.

php asp will serve the content , same way as static html does exept that the page will tell the server what to send before scraping it all up in one body. So if you change anything after the page has loaded your changes will still not be reflected in your code.

But for as long as ypu are happy - it doesn't matter, regards.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.