Home > Questions and Answers > General Questions

LP Coding Help Needed (9)


07-29-2011 07:38 PM #1 minh1204 (Member)
LP Coding Help Needed

Looking to show a particular image on the landing page based on the keyword. I'm using cpvlab as my tracker. Can anyone help?

Thanks


07-29-2011 07:44 PM #2 bbrock32 (Administrator)

Here ya go :

Put this on top of your lp and change pic names and keywords

[PHP]
<?
$kw=$_GET["target"];
if($kw="google.com")
$img="pic1.jpg";
if($kw="yahoo.com")
$img="pic2.jpg";
if($kw="bing.com")
$img="pic3.
?>
[/PHP]

and this where you want the image to be shown :

HTML Code:
<img scr="<?=$img?>" />


07-29-2011 07:49 PM #3 minh1204 (Member)

wow, fast service. thanks


07-29-2011 07:52 PM #4 minh1204 (Member)

Also, will this work with a partial match or is it exact match?

for example if i use if($kw="google")
will the same image also show for google.com, google.net and google.org?

thanks again


07-29-2011 08:02 PM #5 thenoto (Member)

For partial matches, you are going to need to use preg_match. Something like this:

Code:
<?php
$target = $_GET['target'];

if (preg_match('/google/', $target) == 1) {
	$image = "google.jpg";
} elseif (preg_match('/yahoo/', $target) == 1) {
	$image = "yahoo.jpg";
} else {
	$image = "bing.jpg";
}

?>


07-30-2011 01:25 AM #6 index (Member)

[PHP]
<?
$kw=$_GET["target"];
if($kw="google.com")
$img="pic1.jpg";
if($kw="yahoo.com")
$img="pic2.jpg";
if($kw="bing.com")
$img="pic3.

[/PHP]

is that shorthand or something? shouldn't it be?....

[PHP]
<?
$kw=$_GET["target"];

if($kw="google.com"){
$img="pic1.jpg";
}
if($kw="yahoo.com"){
$img="pic2.jpg";
}
if($kw="bing.com"){
$img="pic3.jpg";
}
?>
[/PHP]


07-30-2011 08:14 AM #7 optimex (Member)

This is how I code PHP in my mind:

<?
if the keyword is walmart.com then echo img3
}
?>


07-30-2011 09:00 AM #8 index (Member)

Quote Originally Posted by optimex View Post
This is how I code PHP in my mind:

<?
if the keyword is walmart.com then echo img3
}
?>
yea me too, but I didn't know the curly braces aren't required. learned something new!


07-31-2011 07:13 AM #9 jmagcase (AMC Alumnus)

Here's how I would code it:
[PHP]
<?php
$kw = strtolower(trim($_GET["target"]));

$default_img = 'default.jpg';

switch($kw)
{
case 'google.com':
case 'goo.gl':
$img = 'pic001.jpg';
break;
case 'yahoo.com':
case 'yahoo.net':
$img = 'pic002.jpg';
break;
case 'imgrind.com':
$img = 'grindhard.png';
default;
$img = $default_img;
break;
}

?>
[/PHP]


Home > Questions and Answers > General Questions