Jump to content

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


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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.