Hello, I have a dating site http://www.usmatch.info, I like to add different dynamic titles to each profile that contain members' usernames, age, etc. so that when viewing each profile, it shows title on the browser. On the home page (index.php), I use the template file (template.php) to get the website header, footer. On my main template page, I added <title><!-- IF "view_profile" -->{username_value},{age_value}<!-- ENDIF --> | {title}</title> Where view_profile.php is the member detail page. username_value & age_value are field names. but when viewing on browser, it shows the actual useraname and age but it lists {username_value},{age_value} on the title. What did I do wrong? I attached 2 files. Please help me. Thanks, Jenny.
As far as I can see you didn't use any template engine, outputting just with pure PHP? So why you inserted a code with such a syntax? If you use no Smarty etc. you need to embed php chunks into your HTML. I.e. to output var you can insert <?php echo $var; ?> PHP: or <?=$var?> //(short, but not recommended by PHP gurus) PHP: For conditional blocks in HTML you can use constructions like this: <?php if ($cond) { ?> <b>Cond is true</b> <?php } else { ?> <b>Cond is false</b> <?php } ?> PHP:
Yes. I do not use any Engine or Smarty. Here is what I changed but don't work. <?php if ($view_profile) { ?>{username_value},{age_value}<?php } else { ?>{title}<?php } ?> I am a newbie in PHP, can you please help me in detail? Thank you very much!!!
Wrong, you should also replace your {var} blocks, there is no {} directives. Something like this: <?php if ($view_profile) echo $username_value.','.$age_value; else echo $title; ?> PHP: Of course you need to have variables $view_profile, $username_value, $age_value, $title assigned in this point, I didn't check if you already have them declared.
Hello, I tried exactly what you said but nothing happened. When I viewed the source, it does not have any title tag in it. Can you please advice? Thanks.
Assure you have variables $view_profile, $username_value, $age_value, $title assigned. Sorry I have no time to make "step-by-step manual for noobs" or analyze and write code for you. This topic contains all needed information.
I got them from view_profile php page and they are sb_city, sb_state. Here they are from the view_profile page: <? echo "<a href='search_results.php?city=".$sbrow_off["sb_city"]."' class='small_link' title='All members from ".$sbrow_off["sb_city"]."'>".$sbrow_off["sb_city"]."</a>, "; echo "<a href='search_results.php?state=".$sbrow_off["sb_state"]."' class='small_link' title='All members from ".$sbrow_off["sb_state"]."'>".$sbrow_off["sb_state"]."</a>, "; $country=mysql_fetch_array(mysql_query("select * from sbdtng_country where id=".$sbrow_off["sb_country"])); echo "<a href='search_results.php?country=".$sbrow_off["sb_country"]."' class='small_link' title='All members from ".$country["country"]."'>".$country["country"]."</a>"; Thanks!
I tried this time and it worked but not perfectly. here is what I tried: <?php if ($view_profile) echo $username.','.$gender; else echo $title_str; ?> The username shows up on the title tag but It added a ":" semicolon after that, and I don't know why it shows that semicolon; and the gender value does not show at all. If you look at this link, you will see that. www.usmatch.info/dating_match3506150.html Please help me. Big thanks!!! Jenny.