Forum Moderators: coopster

Message Too Old, No Replies

Changing page title using PHP and Value from DB

         

smartcard

12:19 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



I'm trying to write a PHP page that takes values from two db fields to
generate the title meta tag from a value in my database. I've got all the
database connection stuff working but the problem is that I can only show
one field info as a title.

The following is working file, where it is getting only the value of
$strBrandName and showing it well.
<title><?php echo $strBrandName + $strModel;?></title>

When I want to combine the value of BrandName and Model it is not working.
<title><?php echo $strBrandName + $strModel;?></title>

I think may be my "+" is wrong!

Can anyone help me please? I've looked in my book and on Google but can't
find any code examples.

Thanks.

ppg

12:40 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



What your after is string concatenation.

The concatenation operator in php is the full stop (period)

I think you'd want something like:

$strBrandName . ' ' . $strModel

(putting a space between the brand and model)

And welcome to WebmasterWorld btw.

smartcard

2:22 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



Thanks a lot, it works well.