Jump to content


Rating system

  • Please log in to reply
2 replies to this topic

#1 ltoto

  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 02:38 PM

What i want to do is not a system where people can rate, but something where there will be a hotel which is  stars, so i would want to show four stars , or if it is 5 i would want to show 5.

this is the code of the page i would want to use it on:

mysql_select_db($database_conTotal, $conTotal);
$query_rsHotels = "SELECT * FROM tabHotel";
$rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error());
$row_rsHotels = mysql_fetch_assoc($rsHotels);
$totalRows_rsHotels = mysql_num_rows($rsHotels);

$sql="SELECT * FROM tabHotel WHERE regionId = $id";
$result = mysql_query($sql);
if (!$result) {
   die('Invalid query: ' . mysql_error());
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\">";  
	// List the hotels
   echo " <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"country\">".$image."</div> <div class=\"hotelcontent\">".$description."</div><h3>".$rating."</h3>\n";


i would want to you it on the $rating part

in the backend of the site, the CMS, they can choose the ration via a drop down menu, either 3 start, 4 star or 5 start

the code for the dropdown is this:

<select name="selectRating" id="selectRating" title="<?php echo $row_rsAccomedit['hotelRating']; ?>">
              <option value="3">3 Star</option>
              <option value ="4">4 Star</option>
              <option value ="5">5 Star</option>
            <td><input name="hidId" type="hidden" id="hidId" value="<?php echo $row_rsAccomedit['Id']; ?>"></td>
            <td><input name="Submit" type="submit" class="btn" value="Edit"></td>
        <input type="hidden" name="MM_update" value="form1">

any ideas?

#2 otuatail

  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 19 September 2006 - 03:31 PM

You could sort by rating. Maybe have 5 images for effect But the next line needs changing.
$sql="SELECT * FROM tabHotel WHERE regionId = $id";
$sql="SELECT * FROM tabHotel WHERE regionId = " . $id;

#3 HuggieBear

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

Posted 19 September 2006 - 03:44 PM

You could sort by rating. Maybe have 5 images for effect But the next line needs changing.

No it doesn't, there's nothing wrong with that code.  regionId is an integer, meaning no single quotes are required and as the $id is inside double quotes, the variable will be read, not a literal string.

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users