Jump to content

Please help me with this. I know it's simple but I cannot get it


robert.access

Recommended Posts

Hi all! Please help me to implement this code:

 

<img src="img/<?=(($item_details["sticky"]==1)?"img1.gif":"img2.gif");?>">

 

in here:

 

$browse .= '<tr class="contentfont ' . $background . '"> '.

    ' <td><img src="img/<?=(($item_details["sticky"]==1)?"img1.gif":"img2.gif");?>"><a href="' . $nte_link . '">' . $item_details['name'] . '</a> ' . item_pics($item_details) . '</td> '.

  '</tr> ';

 

 

The output source code it's the same and I need it to be executed... :confused:

 

 

Thank you in advance!

Hi robert.access,

 

Your code doesn't make sense and also is using the incorrect syntax.  To have the correct synatx your code should read:

 

Even with the correct syntax you're just assigning the number "1" to the "$item_details["sticky"]" variable.

 

Hope this helps.

Thank you very much Bricktop, for your answer but I really didn't understand.

 

this code I take it from a page and it's working:

 

<img src="img/<?=(($item_details["sticky"]==1)?"img1.gif":"img2.gif");?>">

 

I want to put on other page to show me img1 or img2, I mean if sticky selected show img1 else show img2.

 

Can you provide me the right code? Thanks!

Oh, I see that now, sorry I didn't quite understand what your first post was asking.

 

So, if that code is working on one page but not another, it's preobably because you're not passing the $item_details["sticky"] value.  Where does this variable come from?

from database! if I understand your question (sorry, noob here)

 

I vant to convert this one <img src="img/<?=(($item_details["sticky"]==1)?"sticky.gif":"arr_it.gif");?>">

 

 

in a friendly code to implement on a page like this:

 

$browse.= '<tr> '.

'<td align="center"><img src="img/above code here"></td> '.

'</tr> ';

So, if that code is working on one page but not another, it's preobably because you're not passing the $item_details["sticky"] value.  Where does this variable come from?

What?

 

It's plain & simple syntax errors:

<?php
$browse .= "<tr class=\"contentfont ".$background."\">\n
          	<td><img src=\"img/".(($item_details["sticky"] == 1) ? "img1.gif" : "img2.gif")."\"><a href=\"".$nte_link."\">".$item_details['name']."</a>".item_pics($item_details)."</td>\n
           </tr>";
?>

Thank you very much!  ;) something like that but on source code page I have:

 

<img src=\"img/".(($item_details["sticky"] == 1) ? "img1.gif" : "img2.gif")."\">

 

instead: <img src="imgx.gif">  :-[

 

Any other ideeas?

Thanks anyway.

Have you copied the code I pasted rather than just ammending yours?

You are using php shorthand echo tags within a variable container (invalid) and also enclosing varaibles in singles quotes '. When used in a string this prints the syntax rather than the parsed code.

 

What I have posted is valid.

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.