Repeating an image according to a value from the database |
[eluser]victorche[/eluser]
I have a simple problem, which makes me crazy since yesterday. Let me show you the code: Code: $rows = $this->users->all_users(); // This gives me an array of all users. I just want to display a smile emoticon for the rating, instead of a number. So, for example if an user has rating 8, I want to display one .gif 8 times. Like this (view file): Code: {rows} Code: {rows} Please, help me... As this makes me really crazy
[eluser]victorche[/eluser]
One more thing ... I know, I can replace the rating number with the images, using jQuery for example. But I want to manage with this in the code. Controller side, I mean. So how can I repeat one image, when I have the repeating value from the database? Please, give me a hint...
[eluser]wh1tel1te[/eluser]
I don't think you can do that with pseudo-variables (template parsing). You will have to use straight PHP. Code: <?php
[eluser]victorche[/eluser]
That's strange, I thought it would be really easy task. Anyway, thanks for your help! Maybe someone else can give a hint here...
[eluser]wh1tel1te[/eluser]
The template parser class is very basic. All it can do is output variables, and loop through arrays. It cannot loop through a certain number as you want it to do. You will have to use straight PHP rather than pseudo-variables, as I suggested above.
[eluser]victorche[/eluser]
[quote author="wh1tel1te" date="1300669753"]The template parser class is very basic. All it can do is output variables, and loop through arrays. It cannot loop through a certain number as you want it to do. You will have to use straight PHP rather than pseudo-variables, as I suggested above.[/quote] Really thanks! This was a really useful information. And because I don't want php code in my templates... I found another solution. Thanks again! |
Welcome Guest, Not a member yet? Register Sign In |