Jump to content

Recommended Posts

Here's my chunk of code:

 

<?php
if (trim($row['altPhoto']) == 'None') 
{
?>
<td width="21%" rowspan="5"><a id="imageurl" ><img id="Rotating1" border="0"></img></a></td>
<script language="JavaScript">
function RotateImages(Start)
  {
      var a = new Array("<?php echo "$img{$row['Photo']}"; ?>","<?php echo "$img{$row['altPhoto']}"; ?>");
      var c = new Array("<?php echo $itemurl; ?>", "<?php echo $itemurl; ?>");
      var b = document.getElementById('Rotating1');
      var d = document.getElementById('imageurl');
      if(Start>=a.length)
          Start=0;
      b.src = a[start];
      d.href = c[start];
      window.setTimeout("RotateImages(" + (Start+1) + ")",3000);
  }
RotateImages(0);
</script>
<?php
}else {
?>
<td width="21%" rowspan="5"><img src="<?php echo "$img{$row['Photo']}"; ?>"></td>
<?php
}
?>

 

The code is SUPPOSED to execute the else when altPhoto contains something other than 'None' but instead, it executes it when altPhoto does contain 'None'. Can someone explain why that is?

 

In other words the code should be doing this when altPhoto = None:

 

Does altPhoto contain None? If yes = show only Photo. If no = show javascript stuff.

 

I guess the matter is whether the code is working backwards or I'm understanding the code backwards.

Link to comment
https://forums.phpfreaks.com/topic/205960-code-is-working-backwards/
Share on other sites

the database had somehow reconfigured itself

 

LOL. No, databases don't do things like that. They only do exactly what you tell them to do and you must always check that you have configured something the way you want or that your data is actually what you expect, especially when your code that is dependent on that data does not do what you expect.

 

From my signature:

Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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