954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php switch case hyperlink "title"

hi all,

Im trying to add a "title" to a switch case statement below, but for some reason im unable to complete, what I thought was a simple task.
Hope someone can help and explaine the reasons why
cheers, Lloyd

switch($ad)
{
	case "add1.gif";
	header("Location: http://www.google.co.uk");	
	break;

	case "add2.gif";
	header("Location: http://www.youtube.com");	
	break;
LloydFarrell
Junior Poster
101 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

The "case" end with : not ;

switch($ad)
{
	case "add1.gif":
	header("Location: http://www.google.co.uk");	
	break;
 
	case "add2.gif":
	header("Location: http://www.youtube.com");	
	break;
}
amd_k8
Light Poster
49 posts since Jan 2010
Reputation Points: 12
Solved Threads: 11
 

I dont understand what you mean ????

Do you mean, its not possible ???

The "case" end with : not ;

switch($ad)
{
	case "add1.gif":
	header("Location: http://www.google.co.uk");	
	break;
 
	case "add2.gif":
	header("Location: http://www.youtube.com");	
	break;
}
LloydFarrell
Junior Poster
101 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

Jeez Luis - amd_k8 just told you to place a colon at the end of your case syntax as opposed to ending with a semi-colon.

Do you mean, its not possible ???

It's not possible for you to replace a semi-colon with a colon??? *sigh*

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

Doh.... I do say sorry for missing that, what a complete a$$......

I have tried adding a "title" tag in many ways but still missing the point,

I have tried the following

case "add1.gif" title='test':
	header("Location: http://www.google.co.uk");	
	break;

case "add1.gif":
	header("Location: http://www.google.co.uk" title='test');	
	break;

case "add1.gif":
                title="test";
	header("Location: http://www.google.co.uk" title='test');	
	break;

case "add1.gif":
                title="test":
	header("Location: http://www.google.co.uk");	
	break;
case "add1.gif":
	header("Location: http://www.google.co.uk");	
                title="test":	
                break;


Im not sure if theres anyother place to place the title, any pointers on this would be great

LloydFarrell
Junior Poster
101 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

What exactly are you trying to accomplish with the "title" statement?

Lsmjudoka
Junior Poster in Training
75 posts since Apr 2009
Reputation Points: 10
Solved Threads: 9
 

The header() is usually a redirecting function, so title will not show up anywhere. Unless you have a 'delay' that shows some text before redirect.

header('Refresh: 5; url=http://www.mysite.com/');
echo $title . " You will be redirected in 5 seconds";


Note that url parameters in headers should be FULL urls including the 'http://' bit.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

The header() is usually a redirecting function, so title will not show up anywhere. Unless you have a 'delay' that shows some text before redirect.

header('Refresh: 5; url=http://www.mysite.com/');
echo $title . " You will be redirected in 5 seconds";

Note that url parameters in headers should be FULL urls including the 'http://' bit.

Hi, thanks for posting, I have just learnt a new piece of code from you.

What I am trying to do, Is when someone hovers over the img that is displayed, Id like it to show a "title text tag" before the user clicks the image to go to the url ??

Thanks for your input,

Lloyd

LloydFarrell
Junior Poster
101 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

That needs to be done in the html tag, PHP's "header" function doesn't do that. Use the "title" attribute, example:

<img src="ad1.jpg" title="Ad description here" />


Edit: Additionally, unless there's a specific reason you need to use a header for the link you would be just as well off with using an image link like this:

<a href="http://www.google.co.uk"><img src="ad1.jpg" title="Ad description here" /></a>
Lsmjudoka
Junior Poster in Training
75 posts since Apr 2009
Reputation Points: 10
Solved Threads: 9
 

Yeah, รจ molto confuso. I can't understand why you'd need to use header. Just a normal html link should suffice - with or without image.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

title for the image should be with ... "Swich" statement execute only from server side ( in this case you can use only after the user click on that image ) ... For displaying title at the hover time , you can go for specifying title with or javascript or advanced AJAX scripts ... Refer the following urls for switch case http://php.net/manual/en/control-structures.switch.php http://www.phpmysqlbrain.com/syntax/php-switch-case/ http://www.w3schools.com/PHP/php_switch.asp

syamsasi
Newbie Poster
19 posts since Aug 2010
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: