Jump to content

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


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.

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.