LexHammer Posted December 10, 2009 Share Posted December 10, 2009 I have 7 codes that i want to display in a row one next to another. The first is {$ads->ads_display('1')}, the second {$ads->ads_display('2')} and so on... They appear one under the other. I want them to appear like this: @ @ @ @ @ @ Can you pls give me the code that i need for that... Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/ Share on other sites More sharing options...
Adam Posted December 10, 2009 Share Posted December 10, 2009 echo $ads->ads_display('1') . $ads->ads_display('2') . $ads->ads_display('3') . $ads->ads_display('4') . $ads->ads_display('5') . $ads->ads_display('6') . $ads->ads_display('7'); ??? Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974679 Share on other sites More sharing options...
Deoctor Posted December 10, 2009 Share Posted December 10, 2009 or else u can also use this for($i=1;$i<=7;$i++) { echo $ads->ads_display('$i'); } Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974693 Share on other sites More sharing options...
LexHammer Posted December 10, 2009 Author Share Posted December 10, 2009 Sorry guys, but i forgot to say that its for tpl file, not for php... What will be the code for tpl? Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974696 Share on other sites More sharing options...
Adam Posted December 10, 2009 Share Posted December 10, 2009 I assume you mean for SMARTY? Then you pretty much have the code.. {$ads->ads_display('1')} {$ads->ads_display('2')} {$ads->ads_display('3')} {$ads->ads_display('4')} {$ads->ads_display('5')} {$ads->ads_display('6')} {$ads->ads_display('7')} Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974697 Share on other sites More sharing options...
LexHammer Posted December 10, 2009 Author Share Posted December 10, 2009 Yes, SMARTY. With that code, they are displayed in a column. I dont want that! I need them to be displayed in a row. Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974705 Share on other sites More sharing options...
Adam Posted December 10, 2009 Share Posted December 10, 2009 Your "ads_display" method could be appending a '<br />' to the return value, or wrapping it within a block element. Can't say for sure without seeing the code though.. Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974736 Share on other sites More sharing options...
LexHammer Posted December 10, 2009 Author Share Posted December 10, 2009 This is the code for the ads_display. Its jut showing small picture with redirect url <div> <div Xstyle='float:left'> <a href='http://www.****.com/***/'> <img src=http://www.****.com/./uploads_user/1000/2/0_4230.jpg width=50 border=0> </a> </div> <div></div> </div> Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974748 Share on other sites More sharing options...
Adam Posted December 10, 2009 Share Posted December 10, 2009 Well by default DIVs are block elements that will appear on a new line. Look at your code.. <div> <div Xstyle='float:left'> <a href='http://www.****.com/***/'> <img src=http://www.****.com/./uploads_user/1000/2/0_4230.jpg width=50 border=0> </a> </div> <div></div> </div> They're each obviously going to appear on a new line. I think you were on the right track before with the "float:left"; though I'm not sure why there's an "X" before the style attribute? Because there's a parent DIV to the floated DIV though, you're still going to end up with each block on a new line. Float the most parent DIV of each block of code basically. <div style="float: left;"> <a href='http://www.****.com/***/'> <img src=http://www.****.com/./uploads_user/1000/2/0_4230.jpg width=50 border=0> </a> </div> Give that a try, stripped out some of the useless code. You'll probably need to use "clear: both" after. Just to add though, is there any need for them to be wrapped within a div? Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974765 Share on other sites More sharing options...
LexHammer Posted December 10, 2009 Author Share Posted December 10, 2009 I used your code, but no change at all, they are still in a column Just to tell you, that i have very low php skills so dont ask me to do anything:) I just can copy paste the code you give me and adjust it with my content... What about if the ads_display codes are inserted itno in a table? Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974788 Share on other sites More sharing options...
Adam Posted December 10, 2009 Share Posted December 10, 2009 Heh noo, don't use tables. As I said before is there any special reason why these images need to be wrapped in a div? Styling purposes or anything? If not just remove it so you just have the image: <a href='http://www.****.com/***/'> <img src=http://www.****.com/./uploads_user/1000/2/0_4230.jpg width=50 border=0> </a> Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974790 Share on other sites More sharing options...
LexHammer Posted December 10, 2009 Author Share Posted December 10, 2009 I removed the div and still no change... Just a little change in the possition of the upper add. Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974798 Share on other sites More sharing options...
Adam Posted December 10, 2009 Share Posted December 10, 2009 Can you post more code? No reason why, if that's all 'ads_display()' returns, that they should be displayed one per line.. Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974811 Share on other sites More sharing options...
LexHammer Posted December 10, 2009 Author Share Posted December 10, 2009 This is the code... No other code. Just the $ads->ads_display('1') or 2-3-4 and the code for the ads_display... Isnt there any other way to make them appear in row... Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-974906 Share on other sites More sharing options...
LexHammer Posted December 11, 2009 Author Share Posted December 11, 2009 Anybody? Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-975299 Share on other sites More sharing options...
Adam Posted December 11, 2009 Share Posted December 11, 2009 As I said, can you show more code -- that creates and returns the HTML? Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-975300 Share on other sites More sharing options...
LexHammer Posted December 11, 2009 Author Share Posted December 11, 2009 I dont know what else to show you... this is all i got. The div was because of an option that can have text comment for the ad, but no need of that. Here is the row code without the div. <a href='[userprofile]'> <img src=[userphoto] width=[userphotowidth] border=0> </a> That will display the user's photo on the top of the page and when somebody click on it, he will be redirected to the profile. I think that making the pictures in a table with 10 pictures/row will be good if there is no other way now... Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-975333 Share on other sites More sharing options...
LexHammer Posted December 11, 2009 Author Share Posted December 11, 2009 I made it with a table... With border 0 its exactly what i wanted. If you or anybody else cant come up with something else, the table is ok for me... Link to comment https://forums.phpfreaks.com/topic/184627-how-to-display-objects-in-a-row/#findComment-975336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.