Repeating an image according to a value from the database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Repeating an image according to a value from the database (/showthread.php?tid=39769) |
Repeating an image according to a value from the database - El Forum - 03-20-2011 [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 Repeating an image according to a value from the database - El Forum - 03-20-2011 [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... Repeating an image according to a value from the database - El Forum - 03-20-2011 [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 Repeating an image according to a value from the database - El Forum - 03-20-2011 [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... Repeating an image according to a value from the database - El Forum - 03-20-2011 [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. Repeating an image according to a value from the database - El Forum - 03-20-2011 [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! |