Jump to content

Newbie - Making an image a link


DarrenG

Recommended Posts

Hi

 

I am new to php and have inherited some code to change. At the moment I have a page that has an icon and then some php that generates text that is a link to filter a list. I now need to remove the text and make the icon the link. Any ideas how this would be done?

 

Here is the current code snippet:

 

<?php

$logo_size = array(18, 17);
$logo_image = "";

echo $html->image('icons/new.png', array(
'alt'=>'New Product Icon',
'width'=>$logo_size[0], 
'height'=>$logo_size[1],
'border'=>'0',
'class'=>'ProductLogo'));

$queryString_newproducts = str_replace("data[Product][check_1]=&", "data[Product][check_1]=1&", $queryString);
echo $paginator->sort(' New Product', 'product', array('url'=>array('?'=>$queryString_newproducts)));

?>

 

Any help would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/204771-newbie-making-an-image-a-link/
Share on other sites

Well, I don't recognize what you're using to create that $html object, but looking at the code you listed makes me think you may be able to do something like this:

echo $html->image('icons/new.png', array(
'alt'=>'New Product Icon',
'width'=>$logo_size[0], 
'height'=>$logo_size[1],
'border'=>'0',
'onclick'=>'window.location=\'somepage.php\'',
'style'=>'cursor:pointer;',
'class'=>'ProductLogo'));

From what I can gather the first part of the php code is for the image. Then the next 2 lines generate the filter and paginate it on the screen:

 

<?php

...

$queryString_newproducts = str_replace("data[Product][check_1]=&", "data[Product][check_1]=1&", $queryString);
echo $paginator->sort(' New Product', 'product', array('url'=>array('?'=>$queryString_newproducts)));

?>

 

I think I need to somehow get these 2 lines of code to work on the image icon. If I'm way off the mark I apologize but I think that is what I need to do.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.