wispas Posted December 31, 2009 Share Posted December 31, 2009 i want to create a star system for my site. what i am doing is creating a variable with a number and want it to output a number of stars based on my variable. can this be achieved. not sure if i am on right steps, but i currently have a while loop set up <?php $starter = 0; $empty = 5; // echo $empty; while ($starter < $empty){ $starter = $starter + 1; echo $starter; } ?> this gives me the following: 12345 instead of numbers i want it to loop the same image and output stars based on my $empty variable. is this possible? Link to comment https://forums.phpfreaks.com/topic/186752-convert-while-loop-number-to-images/ Share on other sites More sharing options...
JustLikeIcarus Posted December 31, 2009 Share Posted December 31, 2009 Cant you just change the echo statement to output the image? like echo '<img src="your star image" />'; Link to comment https://forums.phpfreaks.com/topic/186752-convert-while-loop-number-to-images/#findComment-986226 Share on other sites More sharing options...
wispas Posted December 31, 2009 Author Share Posted December 31, 2009 Someone showed me on another forum. Works Perfectly: for($i = 0; $i < 5; $i++) echo '<img src="path/to/star.gif" alt=""/>'; Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/186752-convert-while-loop-number-to-images/#findComment-986229 Share on other sites More sharing options...
JustLikeIcarus Posted December 31, 2009 Share Posted December 31, 2009 OK looks like that should work providing you replace the 5 with the actual number of stars you want Link to comment https://forums.phpfreaks.com/topic/186752-convert-while-loop-number-to-images/#findComment-986235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.