Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

php help

Status
Not open for further replies.
Joined
Nov 7, 2005
Posts
1,398
Reaction score
28
Wonder if any of you can help, I am looking for the little bit of php code that would basically say

If the url of the page is domain.co.uk/product.php?search+term
Then display "this text"

Just looking to add some text on a specific page that uses a template so can't hard code it.
 
I would advise asking at phpfreaks.com/forums, they will give you the code.

Rgds
 
Scott - not sure exactly what you are looking for, can you explain again and I'll help if I can.

Is this just on one page or throughout the site?

Do you want to display the search term or some other text?
 
If the url of the page is domain.co.uk/product.php?search+term
Then display "this text"

On product.php put this:

PHP:
<?php
if($_SERVER['QUERY_STRING']=='search+term') {
  echo "this text";
}
?>

Jee
 
In Lumens - renewable energy efficient contemporary lighting I created categories using search terms like bathroom lights, I'd like to add some text to those category pages so if the page was:

/productlist.php?q=bathroom+light

I want to add a paragraph of text to help make the page more unique.

Edit: Thanks Jee I'll give that a whirl!
 
Last edited:
I'd like to add some text to those category pages so if the page was:

/productlist.php?q=bathroom+light

Now that changes things slightly ;)

PHP:
<?php
if($_GET['q']=='bathroom light') {
  echo 'abc';
}
?>
 
Hell of a long way of doing that if there are multiple items.

PHP:
switch (strtolower($_GET['q'])) { //without the strtolower bathroom, Bathroom, BathRoom are all different terms
//you shouldnt really accept user inputted data directly as it allow code injection so sanitize the q variable first.
	case "bathroom light":
		echo 'This is a bathroom light';
	break;
		
	case "toilet light":
		echo 'this is a toilet light';
	break;

	default:
		echo 'default product';
	break;
}

Would be more suitable for a product guide.

I use this kinda switch to draw data from a mysql database on queries but can be used this way too.
 
One last thing, is there a way to only make the text appear in
this url : productlist.php?q=bathroom+light
and not
this one: productlist.php?q=bathroom+light&iListOffset=10
 
You would need to use Mod_Rewrite to do that the easiest way, otherwise you would need to edit the pagination code to use sessions, cookies or post data instead to track what page of the search results you was up to.

I suck at mod_rewrite (and regex) but a quick search of the net will tell you most you need to know.

Unless its proprietry software you may find that someone has already made SEO friendly URLs for it, much like this forum uses :)
 
One last thing, is there a way to only make the text appear in
this url : productlist.php?q=bathroom+light
and not
this one: productlist.php?q=bathroom+light&iListOffset=10

PHP:
<?php
if(strtolower($_GET['q'])=='bathroom light' && !isset($_GET['iListOffset'])) {
  echo 'abc';
}
?>

Try that...
 
o0o I think I misread your post :p

I thought you meant modify the URL in the browser not the output, I was on the phone when I read it.

Yeah the above should work by jee :)

Maybe worth testing for the value of 'iListOffset', incase someone deletes just the numerical value to get back the homepage.
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom