NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP Help

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 01-31-2011, 07:01 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 65
Spawn is an unknown quantity at this point
 



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.
Spawn is offline   Reply With Quote
Old 01-31-2011, 07:48 AM   #2 (permalink)
NamePros Regular
 
tiawood's Avatar
Join Date: Oct 2008
Location: Florida
Posts: 450
tiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to behold
 




Are you wanting to show either $q or $type or do you want them both to show if they are both not empty?
tiawood is offline   Reply With Quote
Old 01-31-2011, 07:55 AM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 65
Spawn is an unknown quantity at this point
 



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 :/
Spawn is offline   Reply With Quote
Old 01-31-2011, 08:04 AM   #4 (permalink)
NamePros Regular
 
tiawood's Avatar
Join Date: Oct 2008
Location: Florida
Posts: 450
tiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to beholdtiawood is a splendid one to behold
 




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";
}
tiawood is offline   Reply With Quote
Old 01-31-2011, 08:48 AM THREAD STARTER               #5 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 65
Spawn is an unknown quantity at this point
 



Thanks alot

This worked just as i wanted it

<title><?
if($q != ""){
echo "$q Name of my Website";
}
elseif($type != ""){
echo "$type Name of my Website";
}
else{
echo "Name of my Website";
}
?></title>
Spawn is offline   Reply With Quote
Old 02-04-2011, 04:13 PM   #6 (permalink)
Account Suspended
Join Date: Dec 2008
Location: Boston, Ma
Posts: 650
CrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to all
 



Marrow Donor Program Animal Rescue Autism Autism
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>
CrackFeed.Com is offline   Reply With Quote
Old 02-06-2011, 04:35 AM THREAD STARTER               #7 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 65
Spawn is an unknown quantity at this point
 



Thanks, i should realy use another script or have someone clean up the current one, as this one is quite old, from 2001, but it works just as i want
Spawn is offline   Reply With Quote
Old 04-01-2011, 12:35 AM   #8 (permalink)
New Member
Join Date: Mar 2011
Posts: 3
IslooGuy is an unknown quantity at this point
 



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.
IslooGuy is offline   Reply With Quote
Reply


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

 
All times are GMT -7. The time now is 02:44 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger