| | |
Dynamic Title Generation using PHP and MySql
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Hello all,
For creating dynamic title tags,
I tried using
I get nothing displayed on title ! So i changed the code to,
Its now working. But is this the right way to use title tags in the middle of the code somewhere but not in the actuall <head> section of the page?!
Also, I tried using <meta> tags tooo randomly in the middle of the page code.
Though everything is working fine, i doubt i am actually coding in the wrong way. Is this the proper way to code? I chose this because the first version is displaying me nothing as $pagetitle gets value into it after empty title is displayed
Any advise will be appreciated. Thank you all in advance.
For creating dynamic title tags,
I tried using
php Syntax (Toggle Plain Text)
<title>welcome<?php echo '$pagetitle';?></title> </head> <body> : : <?php : $pagetitle = '$row[2]'; ?> //closing rest of the tags.
I get nothing displayed on title ! So i changed the code to,
php Syntax (Toggle Plain Text)
<html> <head> </head> <body> : : : : : <?php : : : $pagetitle = '$row[2]'; <title>welcome<?php echo '$pagetitle';?></title> ?> //closing rest of the tags.
Its now working. But is this the right way to use title tags in the middle of the code somewhere but not in the actuall <head> section of the page?!
Also, I tried using <meta> tags tooo randomly in the middle of the page code.
Though everything is working fine, i doubt i am actually coding in the wrong way. Is this the proper way to code? I chose this because the first version is displaying me nothing as $pagetitle gets value into it after empty title is displayed

Any advise will be appreciated. Thank you all in advance.
Well. It is correct, but if you want a clean separation between code and layout, I'd suggest you use templates. The html code goes into a template, with variables like title. After setting all your vars, you output the template. Nice and clean. (smarty.net)
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Hi kkeith29 and pritaeas
Now I know how to put it in <head> section and retrieve values at the same time. But let me know , if doing it in the way i did might be a problem?! If not i shall leave it as coded but if there is a problem then i shall remove the <title> tags from the <body> and place it in the head section.
Thank you fr your patience and time.
Now I know how to put it in <head> section and retrieve values at the same time. But let me know , if doing it in the way i did might be a problem?! If not i shall leave it as coded but if there is a problem then i shall remove the <title> tags from the <body> and place it in the head section.
Thank you fr your patience and time.
Last edited by Kavitha Butchi; Dec 4th, 2008 at 9:25 am.
Kavitha
I Love My Indonesia.
I Love My Indonesia.
Aside from what they've said about validation just remove the quotes around the variable. Variables inside '' aren't parsed out so you won't get anything but that string. Either use "" or none at all when only echoing a variable.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
•
•
•
•
Aside from what they've said about validation just remove the quotes around the variable. Variables inside '' aren't parsed out so you won't get anything but that string. Either use "" or none at all when only echoing a variable.
Thankyou fr the valuable piece of info.
Cheers..
Kavitha
I Love My Indonesia.
I Love My Indonesia.
![]() |
Similar Threads
- PHP Dynamic Form HELP! (PHP)
Other Threads in the PHP Forum
- Previous Thread: generating random id and save it into db
- Next Thread: how to connect to remote server usin ssh
| Thread Tools | Search this Thread |
# .htaccess 5.2.10 access alexa apache api array beginner broken cakephp checkbox class clean clients cms code convert cron curl database date directory display dissertation dropdown dynamic echo$_get[x]changingitintovariable... email encode error fairness file folder form forms function functions google hack href htaccess html htmlspecialchars image include indentedsubcategory ip javascript joomla legislation limit link local login mail memberships menu methods multiple multipletables mysql mysqlquery network newsletters oop open passwords paypal pdf persist php provider query radio random redirect remote script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable video voteup web youtube






