Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 20 September 2006 - 08:24 AM

this is what i have done:

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";
}


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?

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 20 September 2006 - 08:39 AM

I'd stick it in a variable...

<?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>
?>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 20 September 2006 - 08:48 AM

for example like this:

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);
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users