robert.access Posted September 25, 2009 Share Posted September 25, 2009 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... Thank you in advance! Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/ Share on other sites More sharing options...
Bricktop Posted September 25, 2009 Share Posted September 25, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924769 Share on other sites More sharing options...
robert.access Posted September 25, 2009 Author Share Posted September 25, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924779 Share on other sites More sharing options...
Bricktop Posted September 25, 2009 Share Posted September 25, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924786 Share on other sites More sharing options...
robert.access Posted September 25, 2009 Author Share Posted September 25, 2009 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> '; Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924791 Share on other sites More sharing options...
JonnoTheDev Posted September 25, 2009 Share Posted September 25, 2009 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924793 Share on other sites More sharing options...
robert.access Posted September 25, 2009 Author Share Posted September 25, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924804 Share on other sites More sharing options...
JonnoTheDev Posted September 25, 2009 Share Posted September 25, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924809 Share on other sites More sharing options...
robert.access Posted September 25, 2009 Author Share Posted September 25, 2009 ok thank you very much for your answer I will try harder to implement what you provide to me. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/175504-please-help-me-with-this-i-know-its-simple-but-i-cannot-get-it/#findComment-924811 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.