...

View Full Version : If Certain User Type, then Replace Image/Link Help



Stickyfan
01-04-2012, 11:59 PM
Please help. I'm trying to replace an image & link only when certain "Dealer" users visit my page. If the user is not a Dealer, the default image and link should be shown.

With my current code, I'm seeing the modified image and link when a Dealer users visits the page, but the problem is that the default image is shown as well (stacked below the Dealer image & link).

I think my problem is that I'm posting the Dealer image and link instead of "replacing" the default image and link. Here's my code:


if($dealer['user_id'] > 0){
print '
<h3>How It Works</h3>
<p>Click on each step to learn more</p>
<p style="text-align:center;"><img alt="" border="0" src="'.D.'uploads/users/images/why-pre-sell-dealer.gif" style="width:465px; height:306px;" usemap="#whatspresell" />
<map id="whatspresell" name="whatspresell">
<area alt="" class="colorbox {iframe:true,height:300,width:300}" coords="156,1,300,49" href="'.D.'files/why-pre-sell-popup.php?id=94" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:625,width:810}" coords="327,77,463,131" href="'.D.'files/why-pre-sell-popup.php?id=95" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:650,width:800}" coords="295,182,440,237" href="'.D.'files/why-pre-sell-popup.php?id=96" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:700,width:900}" coords="156,258,303,302" href="'.D.'files/why-pre-sell-popup.php?id=97" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:400,width:900}" coords="13,179,159,232" href="'.D.'files/why-pre-sell-popup.php?id=98" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:450,width:550}" coords="1,62,134,119" href="'.D.'files/why-pre-sell-popup.php?id=106" shape="rect" />
</map>
</p>
';
}
print '

<h3>How It Works</h3>
<p>Click on each step to learn more</p>
<p style="text-align:center;"><img alt="" border="0" src="'.D.'uploads/users/images/why-pre-sell-2.gif" style="width:465px; height:306px;" usemap="#whatspresell" />
<map id="whatspresell" name="whatspresell">
<area alt="" class="colorbox {iframe:true,height:300,width:300}" coords="156,1,300,49" href="'.D.'files/why-pre-sell-popup.php?id=94" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:625,width:810}" coords="327,77,463,131" href="'.D.'files/why-pre-sell-popup.php?id=95" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:650,width:800}" coords="295,182,440,237" href="'.D.'files/why-pre-sell-popup.php?id=96" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:700,width:900}" coords="156,258,303,302" href="'.D.'files/why-pre-sell-popup.php?id=97" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:400,width:900}" coords="13,179,159,232" href="'.D.'files/why-pre-sell-popup.php?id=98" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:450,width:550}" coords="1,62,134,119" href="'.D.'files/why-pre-sell-popup.php?id=99" shape="rect" />
</map>
</p>
';
?>

The only 2 differences between the Dealer and default sections are the src= image and the ID in the 6th "area". Here's a screen shot of my issue:

http://img600.imageshack.us/img600/2622/screenshot20120104at356.png (http://imageshack.us/photo/my-images/600/screenshot20120104at356.png/)

If you have questions I'll do my best to answer. Thank you!

Spookster
01-05-2012, 12:42 AM
I would imagine then you want to wrap the second image in an else statement otherwise it will print both of them if they are not a dealer.



if($dealer['user_id'] > 0){
// dealer image code
}
else {
// default image code
}


And FYI that is not a very readable way to check if the user is a dealer. Using a variable named $dealer to check for user ids where the user might be a dealer or a non-dealer is just misleading.

Stickyfan
01-05-2012, 01:10 AM
Thank you. That sounds right.

I'm trying to add the else statement, but am having issues working around the "print '" statement. How should I wrap the else statement around it?

Spookster
01-05-2012, 01:26 AM
if($dealer['user_id'] > 0){
print '
<h3>How It Works</h3>
<p>Click on each step to learn more</p>
<p style="text-align:center;"><img alt="" border="0" src="'.D.'uploads/users/images/why-pre-sell-dealer.gif" style="width:465px; height:306px;" usemap="#whatspresell" />
<map id="whatspresell" name="whatspresell">
<area alt="" class="colorbox {iframe:true,height:300,width:300}" coords="156,1,300,49" href="'.D.'files/why-pre-sell-popup.php?id=94" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:625,width:810}" coords="327,77,463,131" href="'.D.'files/why-pre-sell-popup.php?id=95" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:650,width:800}" coords="295,182,440,237" href="'.D.'files/why-pre-sell-popup.php?id=96" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:700,width:900}" coords="156,258,303,302" href="'.D.'files/why-pre-sell-popup.php?id=97" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:400,width:900}" coords="13,179,159,232" href="'.D.'files/why-pre-sell-popup.php?id=98" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:450,width:550}" coords="1,62,134,119" href="'.D.'files/why-pre-sell-popup.php?id=106" shape="rect" />
</map>
</p>
';
}
else {
print '

<h3>How It Works</h3>
<p>Click on each step to learn more</p>
<p style="text-align:center;"><img alt="" border="0" src="'.D.'uploads/users/images/why-pre-sell-2.gif" style="width:465px; height:306px;" usemap="#whatspresell" />
<map id="whatspresell" name="whatspresell">
<area alt="" class="colorbox {iframe:true,height:300,width:300}" coords="156,1,300,49" href="'.D.'files/why-pre-sell-popup.php?id=94" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:625,width:810}" coords="327,77,463,131" href="'.D.'files/why-pre-sell-popup.php?id=95" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:650,width:800}" coords="295,182,440,237" href="'.D.'files/why-pre-sell-popup.php?id=96" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:700,width:900}" coords="156,258,303,302" href="'.D.'files/why-pre-sell-popup.php?id=97" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:400,width:900}" coords="13,179,159,232" href="'.D.'files/why-pre-sell-popup.php?id=98" shape="rect" />
<area alt="" class="colorbox {iframe:true,height:450,width:550}" coords="1,62,134,119" href="'.D.'files/why-pre-sell-popup.php?id=99" shape="rect" />
</map>
</p>
';
}

Stickyfan
01-05-2012, 01:43 AM
Perfect! I was putting the beginning of the else statement below the "print" statement. Thanks very much for your help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum