sandbudd Posted April 9, 2009 Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/ Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805453 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 This works but how do I get it to say coupon instead of the image <a href="/images/coupon/<?php echo $row_Recordset1['coupon']; ?>" target="_blank"><?php echo $row_Recordset1['coupon']; ?></a> Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805459 Share on other sites More sharing options...
redarrow Posted April 9, 2009 Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805461 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 <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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805471 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 redarrow that works great but how can I make it pop up in its own window or do a _blank? Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805473 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 also that has the "show image" next to all the displays Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805478 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 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> Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805509 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805520 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 no its not that easy..lol Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805526 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805537 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 Well right now when it displays it says for example "roastedbean.png" and I want the link to say "Coupon" Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805542 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 Then it is as easy as i say in reply #8: Just put the text "coupon" between the anchor tag: <a href="www.foo.bar">Coupon</a> Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805547 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 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. Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805551 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805565 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 wow that worked...lol... thanks Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805575 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 one last question if there is no coupon how to have it say "no Coupon"? Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805579 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805587 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 perfect...thanks again.. Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805591 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 perfect...thanks again.. Glad i could help Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805594 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 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 https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805600 Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 sorry guys my bad...forgot to delete the old code...works great! Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805607 Share on other sites More sharing options...
mr groovy Posted April 9, 2009 Share Posted April 9, 2009 Maybe if you want a cleaner HTML source, you can check for redundant closing tags. I see in the HTML source closing </a> and </span> tags while there is none opened. Link to comment https://forums.phpfreaks.com/topic/153316-solved-linking-troubles/#findComment-805619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.