Jump to content

PHP if else help needed


kissfreaque

Recommended Posts

I have a rollover problem. I want to use an If/Else here and it is not working. The original code is this:

<td width="111"><a href="resources.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Resources','','navigation/resources1.jpg',0)"><img src="navigation/resources.jpg" alt="Resources" name="Resources" width="111" height="63" border="0" id="Resources" /></a></td>

 

and my new statement depends on a variable, so I wrote this:

<?php if ($ID == "resources")

{ echo ("<td width='111'><img src='navigation/resources2.jpg' alt='Resources' width='111' height='63' /></td>"); }

else { echo ("<td width='111'><a href='resources.php' onmouseout='MM_swapImgRestore()' onmouseover='MM_swapImage('Resources','','navigation/resources1.jpg',0)'><img src='navigation/resources.jpg' alt='Resources' name='Resources' width='111' height='63' border='0' id='Resources' /></a></td>");} ?>

 

So when the variable is false, or "else", I needed to go in and change all the " to ' since it is already in an " ". Everything works except for the rollover. everything here

('Resources','','navigation/resources1.jpg',0)

was already a single ', and I have no clue of how to handle this part. Please help if you can.

Link to comment
https://forums.phpfreaks.com/topic/198739-php-if-else-help-needed/
Share on other sites

No errors here.

<?php 
if ($ID == "resources") { 
echo '<td width="111"><img src="navigation/resources2.jpg" alt="Resource" width="111" height="63" /></td>'; 
} else { 
echo '<td width="111"><a href="resources.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'Resources\',\'\',\'navigation/resources1.jpg\',0)"><img src="navigation/resources.jpg" alt="Resources" name="Resources" width="111" height="63" border="0" id="Resources" /></a></td>';
} 
?>

:) Your origional code.. good lord, it was ugly.

just a thought

 

1. the if in php

2. drop out of php and use nice clean easy to use html/js

3. the else in php

4. drop out of php and use nice clean easy to use html/js

5. the endif in php

 

for me, that makes trying keep track of single/double quotes mute

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.