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'] ."> "; ?> Quote Link to comment 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 Quote Link to comment 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> Quote Link to comment 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'] ."'> "; } ?> Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 no its not that easy..lol Quote Link to comment 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 Quote Link to comment 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" Quote Link to comment 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> Quote Link to comment 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. Quote Link to comment 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>'; } Quote Link to comment Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 wow that worked...lol... thanks Quote Link to comment 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"? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
sandbudd Posted April 9, 2009 Author Share Posted April 9, 2009 perfect...thanks again.. Quote Link to comment 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 Quote Link to comment 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>'; } ?> Quote Link to comment 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! Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.