| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Nov 2006
Posts: 65
![]() | PHP Help Hello i need some php help, i use the following code in the title of my website: <title><? if($q != ""){ echo "$q Name of my Website"; } else{ echo "Name of my Website"; } ?></title> Everything works fine, the problem however is when i want to add another line like this: <title><? if($q != ""){ echo "$q Name of my Website"; } if($type != ""){ echo "$type Name of my Website"; } else{ echo "Name of my Website"; } ?></title So now when i go to the search page it looks like this (in the title): "$q Name of my Website$type Name of my Website", i have tryed to add some break codes, but just cant seem to get it working. |
| | |
| | #2 (permalink) |
| NamePros Regular Join Date: Oct 2008 Location: Florida
Posts: 450
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Are you wanting to show either $q or $type or do you want them both to show if they are both not empty?
__________________ ██ 6 Website HotSpots You May Have Missed | Custom Web Development & Graphic Deals ██ |
| | |
| | THREAD STARTER #3 (permalink) |
| NamePros Member Join Date: Nov 2006
Posts: 65
![]() | Well as it works now when someone do a search, it list that search at the bottom of the page for google to index, so when it gets indexed, it shows the search query in the title of the page for that search. I would also like to have the categories name in the title there is where the $type comes in, but wont work :/ |
| | |
| | #4 (permalink) |
| NamePros Regular Join Date: Oct 2008 Location: Florida
Posts: 450
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | From what I understand, you can do something like this: <title><? if($q != ""){ echo "$q Name of my Website"; } elseif($type != ""){ echo "$type Name of my Website"; } else{ echo "Name of my Website"; } ?></title> Unless $type happens to be undefined or null. Or if you are trying to put them together: if(($q != "")&&($type != "")){ ????: NamePros.com http://www.namepros.com/programming/699675-php-help.html echo "$q Name of my Website | $type Name of my Website"; } elseif($q != ""){ echo "$q Name of my Website"; } elseif($type != ""){ echo "$type Name of my Website"; } else{ echo "Name of my Website"; }
__________________ ██ 6 Website HotSpots You May Have Missed | Custom Web Development & Graphic Deals ██ |
| | |
| | #6 (permalink) |
| Account Suspended Join Date: Dec 2008 Location: Boston, Ma
Posts: 650
![]() ![]() ![]() ![]() ![]() ![]() | I made a few modifications to cut out security risks, if data is being sent via form or url, and to prevent NOTICEs from appearing for undefined variables: Code: <title><?php
if(!empty($_REQUEST['q'])) {
echo htmlspecialchars(strip_tags($_REQUEST['q'])) . ' Name of my Website';
} elseif(!empty($_REQUEST['type']))) {
echo htmlspecialchars(strip_tags($_REQUEST['type'])) . ' of my Website";
} else{
echo 'Name of my Website';
}
?></title> |
| | |
| | #8 (permalink) |
| New Member Join Date: Mar 2011
Posts: 3
![]() | It is good to see that the issue is solved. But i would like to ad that html statments such as break do not work for php. You have to either output a like a command. For example. <?php echo "<br />";?> or use a return meta character such as \n at the end of line and new line will be started. I hope it helps. |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scripts with full resale rights | benc811 | Scripts For Sale | 10 | 10-26-2009 04:43 PM |
| Summer Special: 40% (or more) OFF selected PHP Scripts / Flash Applications | OI2 | Scripts For Sale | 2 | 09-09-2009 06:25 AM |
| PHP License Script v1.31 | bonzer | Scripts For Sale | 4 | 05-30-2009 02:35 PM |
| 77 scripts with re-sell rights $5 | benc811 | Scripts For Sale | 34 | 03-23-2009 11:03 AM |
| Tutorial: How to Install Apache2 MySQL and PHP on Windows | deadserious | Webmaster Tutorials | 35 | 09-21-2005 09:46 PM |