Jump to content

Rating System Code- help needed- **Solved**


ltoto

Recommended Posts

this is what i have done:

[code]while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
  $name = $row['hotelName'];
  $description = $row['hotelDescription'];
  $rating = $row['hotelRating'];
      $image = "<img src=\"../thumb/phpThumb.php?src=../images/hotel_{$row['hotelImage']}&w=100&h=100&zc=1\"  alt=\"Hotel\">"; 
      if ($row['hotelRating'] == 3){
//echo '<img src="star.gif" hspace="2">'
}
else if ($row['hotelRating'] == 4){
//echo '<img src="star2.gif" hspace="2">'
}
else if ($row['hotelRating'] == 5){
//echo '<img src="star3.gif" hspace="2">'
}
   
// List the hotels
  echo " <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div> <div class=\"hotelcontent\">".$description."</div><h3>".$rating."</h3>

\n";
}[/code]


any ideas of where to put these bits which are in it

      if ($row['hotelRating'] == 3){
//echo '<img src="star.gif" hspace="2">'
}
else if ($row['hotelRating'] == 4){
//echo '<img src="star2.gif" hspace="2">'
}
else if ($row['hotelRating'] == 5){
//echo '<img src="star3.gif" hspace="2">'
}


anu suggestions?
Link to comment
https://forums.phpfreaks.com/topic/21377-rating-system-code-help-needed-solved/
Share on other sites

I'd stick it in a variable...

[code]
<?php
if ($row['hotelRating'] == 3){
$star = "star.gif";
}
else if ($row['hotelRating'] == 4){
$star = "star2.gif";
}
else if ($row['hotelRating'] == 5){
$star = "star3.gif";
}

// List the hotels
echo "<div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".$description."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>
?>
[/code]

Regards
Huggie
for example like this:

[code]while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
  $name = $row['hotelName'];
  $description = $row['hotelDescription'];
  $rating = $row['hotelRating'];
      $image = "<img src=\"../thumb/phpThumb.php?src=../images/hotel_{$row['hotelImage']}&w=100&h=100&zc=1\"  alt=\"Hotel\">"; 
$star =
if ($row['hotelRating'] == 3){
$star = "star.gif";
}
else if ($row['hotelRating'] == 4){
$star = "star2.gif";
}
else if ($row['hotelRating'] == 5){
$star = "star3.gif";
}

// List the hotels
echo "<div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".$description."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>
?>

mysql_free_result($rsHotels);
?>[/code]

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.