Jump to content

*2 <img src=X.png> instead of two <img src=X.png>


soltek

Recommended Posts

This may sound weird, but since lately I've found so many weird php built-functions, I chose to give it a try.

 

I'm doing some sort of rating system where the result is given by images of stars.

If the value of that rating is giving me the number seven, it'd display seven stars and here's the deal.

 

I only know to ways to display the seven stars. The first is to display a png width seven stars, the other is to display seven images of one star.

 

Isnt there some simpler thing to do? Like:

$stars = $row['votes']  /// In this example, the votes gives me the number 7

print ("$stars * <img src='star.png width='10px' height='10px' alt=''/>");

 

Sorry if I sound crazy, but I feel kinda dumb coding 55 times the same thing just for the sake of the stars.

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/223362-2-instead-of-two/
Share on other sites

Something like...

function MyStars($quantity) {
$i=0;
$display = "";
while($i<$quantity) {
	$display = $display . "<IMG src  ='star.png' width='10' height='10'>";
	$i++;
}
echo $display;
}

$stars = $row['votes'] /// In this example, the votes gives me the number 7
MyStars($stars);

Link to comment
https://forums.phpfreaks.com/topic/223362-2-instead-of-two/#findComment-1154625
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.