Jump to content

Archived

This topic is now archived and is closed to further replies.

ltoto

Rating system

Recommended Posts

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:

[code]<?php
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";
}

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

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:

[code]<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>
            </select></td>
          </tr>
          <tr>
            <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>
          </tr>
        </table>
        <input type="hidden" name="MM_update" value="form1">[/code]

any ideas?

Share this post


Link to post
Share on other sites
You could sort by rating. Maybe have 5 images for effect But the next line needs changing.
from
$sql="SELECT * FROM tabHotel WHERE regionId = $id";
to
$sql="SELECT * FROM tabHotel WHERE regionId = " . $id;


Share this post


Link to post
Share on other sites
[quote]
You could sort by rating. Maybe have 5 images for effect But the next line needs changing.
from.....[/quote]

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.

Regards
Huggie

Share this post


Link to post
Share on other sites

×

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.