php in title tag of head section of a body

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
s4salman
Forum Newbie
Posts: 7
Joined: Wed Nov 07, 2007 9:03 am

php in title tag of head section of a body

Post by s4salman »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello

i am currently using php to display database information on the web page using query string.
what i want is that database field name "name" could be put in title tag.like this

Code: Select all

<html>
<head>
<title><? title=$name ?></title>
</head>
<body>
some content
</body>
</html>
how i can do this.do i need to open database connection again in title tag.
[s]plz[/s] please someone could write a full code with explanation that can explain this to me.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

You need to establish a database connection, connect to a database, and execute a query to obtain the value for $name -- before the Title tag. It can be anywhere before. But do use the full opening php tag, <?php (not <?).
User avatar
phppage
Forum Contributor
Posts: 126
Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK

Post by phppage »

Take a look at this link from php.net and read the example for pointers http://uk3.php.net/manual/en/ref.mysql.php
To learn some simple MySQL (which I assume is the database platform you are using) try http://www.tizag.com/mysqlTutorial/mysqlquery.php and for further php examples.
Post Reply