Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to combine two values into one string?
Old 04-13-2005, 02:47 PM How to combine two values into one string?
Average Talker

Posts: 17
Trades: 0
I'm a php newbie and I'm working on my php based site, but got stuck abit because I want to update the page title for each page using variables from a database. So I have 2 variables: $category and $title and want them to be part of the page title so that it would look like this:
MySite.com - $category - $title.

Can anybody help find the right code? Thanks in advance.
__________________

Please login or register to view this content. Registration is FREE
lz83ny is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-13-2005, 03:28 PM
Novice Talker

Posts: 9
Trades: 0
I think what you're trying to do is:

PHP Code:
<title>MySite.com - <?= $category ?> - <?= $title ?></title>
Make sure this is not already within PHP tags. I hope this helps.
MarkyH is offline
Reply With Quote
View Public Profile
 
Old 04-13-2005, 09:24 PM
dotcomguy's Avatar
Skilled Talker

Posts: 89
Location: Manchester, UK
Trades: 0
or use print and......

PHP Code:
<title>Your site 

<?
print $var1
print 
$var2;
 
?>

 </title>
__________________

Please login or register to view this content. Registration is FREE
from just $1.85 per post.
dotcomguy is offline
Reply With Quote
View Public Profile Visit dotcomguy's homepage!
 
Old 04-14-2005, 05:00 PM
rvarcher's Avatar
Novice Talker

Posts: 5
Location: OKC, OK
Trades: 0
or just

PHP Code:
echo "<title>MySite.com - $category - $title</title>"
__________________
- Bob
TropicRentals.com:
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
rvarcher is offline
Reply With Quote
View Public Profile Visit rvarcher's homepage!
 
Old 04-14-2005, 06:35 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Of if you have three values that you want to combine into a single value first (in case you want to use it elsewhere on the page):
PHP Code:
$titleValue "MySite.com - $category - $title";

// Now $titleValue is available for use elsewhere in the script.
print "<title>$titleValue</title>"
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Reply     « Reply to How to combine two values into one string?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23942 seconds with 12 queries