Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › I need help with PHP. (Hyperlink Image)
New Posts  All Forums:Forum Nav:

I need help with PHP. (Hyperlink Image)

post #1 of 8
Thread Starter 
Hi guys. I want to find a way to hyper link a image the problem is i cant find any simple solutions. They all fail..


Code:
<td width="180" align="Center" valign="top" class="sidebarregs"><span class="sidebarsubheader">Shop by Brand</span><br />
    <?
     $clickedBrand=false;
     $strsqlBrand="select distinct(cms_t_brand.id),cms_t_brand.brandname,cms_t_brand.brandLogo from cms_t_product,cms_t_brand where cms_t_product.brand_id=cms_t_brand.id and active='Active' and category_id=$strarea order by brandname";
    
    $rs= mysql_query($strsqlBrand);
    while($rsBrand = mysql_fetch_array($rs,MYSQL_ASSOC)){
       $strBrId  = $rsBrand[id];
       $strBrName = $rsBrand[brandname];
       $strBrLogo = $rsBrand[brandLogo];
      
        if($strbrandid!=$strBrId){      

[B]echo '<img src="'.$strBrLogo.'">';[/B]

        }
    }
     
     
 ?>
    
    <td width="15"><img src="../images/spacer.gif" width="15" height="15" /></td>
  </tr>
</table>

I need the image in bold to link the customer to area.php?a=2&b=$strBrId

How do i do this?
Full Of Stuff
(15 items)
 
The nEEEtBook
(13 items)
 
CPUMotherboardGraphicsRAM
AMD Phenom II 1100t X6 MSI 990XA-GD55 GTX 465 SLI Mushkin Ridge Back 
Hard DriveHard DriveOptical DriveCooling
OCZ Agility 3 Seagate 7200.12 Sony 18X DVD-ROM 48X CD-ROM SATA DVD-ROM Drive Scythe MUGEN-2 SCMG-2000 
OSMonitorKeyboardPower
Windows 7 Ultimate Planar SA2311W 3D Monitor Microsoft Keyboard PC Performance & Cooling Silencer 750W 
CaseMouseAudio
Cooler Master HAF 912 [Window Mod] OCZ BEHEMOTH Laser Mouse Realtek 5.1 Onboard 
CPUMotherboardGraphicsRAM
Intel Atom N270 AsusTek 1005HA Mobile Intel 945 Express 1GB DDR2 
Hard DriveOSMonitorKeyboard
OCZ Vertex 2 (Upgrade) Windows 7 Starter 10.1" Wide screen LED Lit Display Full Keyboard 
PowerCaseMouse
40W 19V Asus Adapter 1005HA Case Trackpad 
  hide details  
Reply
Full Of Stuff
(15 items)
 
The nEEEtBook
(13 items)
 
CPUMotherboardGraphicsRAM
AMD Phenom II 1100t X6 MSI 990XA-GD55 GTX 465 SLI Mushkin Ridge Back 
Hard DriveHard DriveOptical DriveCooling
OCZ Agility 3 Seagate 7200.12 Sony 18X DVD-ROM 48X CD-ROM SATA DVD-ROM Drive Scythe MUGEN-2 SCMG-2000 
OSMonitorKeyboardPower
Windows 7 Ultimate Planar SA2311W 3D Monitor Microsoft Keyboard PC Performance & Cooling Silencer 750W 
CaseMouseAudio
Cooler Master HAF 912 [Window Mod] OCZ BEHEMOTH Laser Mouse Realtek 5.1 Onboard 
CPUMotherboardGraphicsRAM
Intel Atom N270 AsusTek 1005HA Mobile Intel 945 Express 1GB DDR2 
Hard DriveOSMonitorKeyboard
OCZ Vertex 2 (Upgrade) Windows 7 Starter 10.1" Wide screen LED Lit Display Full Keyboard 
PowerCaseMouse
40W 19V Asus Adapter 1005HA Case Trackpad 
  hide details  
Reply
post #2 of 8
Code:
<?php
$link = 'area.php?a=2&b=$strBrId';
$src = $strBrLogo
echo '<a href="'. $link .'"><img style="border:none;" src="'. $src .'" /></a>';
?>


Another way of doing it is to it is using a onclick javascript function

Maybe there is another solution using CSS.
post #3 of 8
Quote:
Originally Posted by EduFurtado View Post

Code:
<?php
$link = 'area.php?a=2&b=$strBrId';
$src = $strBrLogo
echo '<a href="'. $link .'"><img style="border:none;" src="'. $src .'" /></a>';
?>
Another way of doing it is to it is using a onclick javascript function
Maybe there is another solution using CSS.

CSS isn't for functionality. The HTML A tag is pretty much the best way here as you described.
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #4 of 8
Quote:
Originally Posted by tompsonn View Post

CSS isn't for functionality. The HTML A tag is pretty much the best way here as you described.

Using CSS you can make a link look like normal text, or text look like a button, a button like a picture.
I'm pretty sure there is a solution to his problem using CSS, making a link look like a picture thumb.gif
post #5 of 8
Quote:
Originally Posted by EduFurtado View Post

Using CSS you can make a link look like normal text, or text look like a button, a button like a picture.
I'm pretty sure there is a solution to his problem using CSS, making a link look like a picture thumb.gif

I took your initial post as if you meant CSS would provide the ACTUAL linking functionality smile.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #6 of 8
Quote:
Originally Posted by EduFurtado View Post

Code:
<?php
$link = 'area.php?a=2&b=$strBrId';
$src = $strBrLogo
echo '<a href="'. $link .'"><img style="border:none;" src="'. $src .'" /></a>';
?>
Another way of doing it is to it is using a onclick javascript function
Maybe there is another solution using CSS.

This is correct! You need to embed the IMG tag inside the A tag.
You can edit the CSS file to manage the image properties, such as width, height, border, etc...
Code:
.container_div a img {
     border: 1px solid #000;
     width: 300px;
}

Edited by d3viliz3d - 11/19/12 at 5:14am
post #7 of 8
Thread Starter 
Quote:
Originally Posted by d3viliz3d View Post

This is correct! You need to embed the IMG tag inside the A tag.
You can edit the CSS file to manage the image properties, such as width, height, border, etc...
Code:
.container_div a img {
     border: 1px solid #000;
     width: 300px;
}

I did end up figuring this out Thanks
Full Of Stuff
(15 items)
 
The nEEEtBook
(13 items)
 
CPUMotherboardGraphicsRAM
AMD Phenom II 1100t X6 MSI 990XA-GD55 GTX 465 SLI Mushkin Ridge Back 
Hard DriveHard DriveOptical DriveCooling
OCZ Agility 3 Seagate 7200.12 Sony 18X DVD-ROM 48X CD-ROM SATA DVD-ROM Drive Scythe MUGEN-2 SCMG-2000 
OSMonitorKeyboardPower
Windows 7 Ultimate Planar SA2311W 3D Monitor Microsoft Keyboard PC Performance & Cooling Silencer 750W 
CaseMouseAudio
Cooler Master HAF 912 [Window Mod] OCZ BEHEMOTH Laser Mouse Realtek 5.1 Onboard 
CPUMotherboardGraphicsRAM
Intel Atom N270 AsusTek 1005HA Mobile Intel 945 Express 1GB DDR2 
Hard DriveOSMonitorKeyboard
OCZ Vertex 2 (Upgrade) Windows 7 Starter 10.1" Wide screen LED Lit Display Full Keyboard 
PowerCaseMouse
40W 19V Asus Adapter 1005HA Case Trackpad 
  hide details  
Reply
Full Of Stuff
(15 items)
 
The nEEEtBook
(13 items)
 
CPUMotherboardGraphicsRAM
AMD Phenom II 1100t X6 MSI 990XA-GD55 GTX 465 SLI Mushkin Ridge Back 
Hard DriveHard DriveOptical DriveCooling
OCZ Agility 3 Seagate 7200.12 Sony 18X DVD-ROM 48X CD-ROM SATA DVD-ROM Drive Scythe MUGEN-2 SCMG-2000 
OSMonitorKeyboardPower
Windows 7 Ultimate Planar SA2311W 3D Monitor Microsoft Keyboard PC Performance & Cooling Silencer 750W 
CaseMouseAudio
Cooler Master HAF 912 [Window Mod] OCZ BEHEMOTH Laser Mouse Realtek 5.1 Onboard 
CPUMotherboardGraphicsRAM
Intel Atom N270 AsusTek 1005HA Mobile Intel 945 Express 1GB DDR2 
Hard DriveOSMonitorKeyboard
OCZ Vertex 2 (Upgrade) Windows 7 Starter 10.1" Wide screen LED Lit Display Full Keyboard 
PowerCaseMouse
40W 19V Asus Adapter 1005HA Case Trackpad 
  hide details  
Reply
post #8 of 8
Haha, I had to do something similar not so long ago.
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › I need help with PHP. (Hyperlink Image)