Jump to content

[SOLVED] linking troubles


sandbudd

Recommended Posts

Hey guys this code displays the image but what I am trying to get it to do is show a link that says coupon and when clicked on it displays the image...

 

<?php echo "<img src=http://www.fortwaynerestaurant.net/images/coupon/".$row_Recordset1['coupon'] ."> "; ?>

Link to comment
Share on other sites

Hi,

 

You could do it with javascript.

Just make the link and put a onClick event in it.

Also give the image a id so you can call it and controll it's properties.

 

The function is getElementById('yourID') to get a handle to it.

Then you can change css properties so you can toggle display.

 

I hope it is helpfull

Link to comment
Share on other sites

example only.

<?php 

echo"<a href='{$_SERVER['PHP_SELF']}?cmd=show'>Show Image</a>";

if(isset($_GET['cmd']) && $_GET['cmd']=="show"){

echo "<img src='http://www.fortwaynerestaurant.net/
images/coupon/".$row_Recordset1['coupon'] ."'> "; 
}
?>

Link to comment
Share on other sites

<html>

<head>
<style>
#myImage {
	display: none;
}
</style>

<script>
function toggle(){
	img = document.getElementById('myImage');
	if(img.style.display == 'none'){
		img.style.display = 'block';
	}else{
		img.style.display = 'none';
	}
}
</script>
</head>

<body>

<img src="image.jpg" id="myImage" />
<span onclick="toggle()">KLIK ME!</span>

</body>
</html>

 

This a simple toggle javascript.

But i think you don't want to do it client sided when i read the other posts.  ;)

Anyway, i hope you ll find a solution that suits you.

Link to comment
Share on other sites

is there a simple way to get this to work and say coupon rather than image.jpg

 

<a href="/images/coupon/<?php echo $row_Recordset1['coupon']; ?>" target="_blank" class="style3"><?php echo $row_Recordset1['coupon']; ?></a>

 

Yes i think so if i understand it correctly, if you allways want is to say "coupon" then simply do this:

<a href="/images/coupon/<?php echo $row_Recordset1['coupon']; ?>" target="_blank" class="style3">Coupon</a>

But it cant be that easy i must miss something.

Link to comment
Share on other sites

no its not that easy..lol

Ok, so you now know i dont quite understand the problem you are facing.

Maybe you can give more details about your situation.

I really would like to help and give suggestions but it's not clear for me what the situation is  :-X

Link to comment
Share on other sites

then it display coupon on all the entire list and they all link to the same image.... here is an example www.fortwaynerestaurant.net and click on asian and scroll to the bottom where is says tttt.

 

Now i see,

there is no image link for every item in the row.

In the HTML source i see that all rows except one has empty links.

You can make a if statement to check if content is present and not just output it without checking.

 

This can be a solution:

 

if(!empty($row_Recordset1['coupon'])){
echo '<a href="/images/coupon/' . $row_Recordset1['coupon'] . '"  target="_blank" class="style3">Coupon</a>';
}

Link to comment
Share on other sites

one last question if there is no coupon how to have it say "no Coupon"?

 

Like this:

<?php
if(!empty($row_Recordset1['coupon'])){
echo '<a href="/images/coupon/' . $row_Recordset1['coupon'] . '"  target="_blank" class="style3">Coupon</a>';
}else{
echo 'no coupon';
}
?>

 

Just add a else block,

it get's executed when the if conditions where false.

 

but

 

i would make the final code like this:

 

<?php
if(empty($row_Recordset1['coupon'])){
//empty() returned true : so there is nothing
echo 'no coupon';
}else{
//empty() returned false so it is NOT true that there is nothing
//so we can print it out:
echo '<a href="/images/coupon/' . $row_Recordset1['coupon'] . '"  target="_blank" class="style3">Coupon</a>';
}
?>

 

To make it more readable, otherwise you check for sometinh being not true.

They both behaive the same but the code looks simpler.

I hope i did not confuse you  ::)

Link to comment
Share on other sites

well tried the same thing with email but it shows up as a link when there is none?

 

<?php
if(empty($row_Recordset1['email'])){
   //empty() returned true : so there is nothing
   echo 'no email';
}else{
   //empty() returned false so it is NOT true that there is nothing
   //so we can print it out:
   echo '<a href="mailto:' . $row_Recordset1['email'] . '"  target="_blank" class="style3">Email</a>';
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.