Converting dynamic repeatable region output on the fly

  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I use DW CS3 for all my editing and I don't know very much about PHP. The goal is to take a repeatable region which displays an average user rating, done via a slightly advanced query using the average function etc and turn it into a combination of Stars(the HTML encoding star graphic) and the half fraction(same HTML format)

Can anyone give me an idea of how to do this?

Many thanks ahead of time!

example of rating as it is now and if you look to the right you will see my rating stars in the drop down menus. I need to get the output to look like this after the SQL has determined the number value. I have tried elseif statements, but I might have used the wrong language approach - again I am no pro.

http://www.allinnia.com/listen.php
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

Wow nothing huh? Is there no neat little function to transform numbers into stars on the fly? The data in question is a repeat region integer from a database. I though there might be a useful conditional statement to transform it on loading, but I don't know very much about PHP.
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

Yeah, I saw this post awhile back and took a look at the example, but I still wasn't crystal clear. I'll give it a shot though.

It seems you just need the query to display a different image. I would create an array of the star.jpgs and then depending on the rating pulled from the database fill in the appropriate jpeg.

Code: [ Select ]
$starz = array("stars1.jpg","stars2.jpg","stars3.jpg","stars4.jpg","stars5.jpg");

// now when you get your star rating from query

$rating = 3; // this one got 3 stars

//now display appropriate image, remember arrays start with 0 so subtract 1

$star_image = $rating - 1;
echo "<img src="/path/to/img/"."$starz[$star_image]">";
  1. $starz = array("stars1.jpg","stars2.jpg","stars3.jpg","stars4.jpg","stars5.jpg");
  2. // now when you get your star rating from query
  3. $rating = 3; // this one got 3 stars
  4. //now display appropriate image, remember arrays start with 0 so subtract 1
  5. $star_image = $rating - 1;
  6. echo "<img src="/path/to/img/"."$starz[$star_image]">";
  • Dorky
  • Novice
  • Novice
  • Dorky
  • Posts: 15

Post 3+ Months Ago

idk dude but i love the cream cheese sig lmao
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

:) ... yeah I don't know if I'm even close. Kinda doubt it.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 51 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.