ltoto Posted October 24, 2006 Share Posted October 24, 2006 Ok So what i have at the moment is something where in the front end of the website it shows a coutry name, and a list of regions within the country. e.gSpain: Murica, Madridthen when they click on the region the list of hotels appear within this region on a new page.In the SQl i have 3 tables, 1 called Country, one called Region, and one called Hotels.Country table:idcountryNameRegion TableidregionnamecountryId ( this is picking up the id from the first table )Hotels tableidhotelnamehotelratingcountrynameregionId( picking the Id up from the region table )hoteltypeand this is the code I have done this in in the front end[code]<?phpif(@$_GET['Id']== "15") { ?><?php $sql="SELECT c.countryName, c.countryImage, r.regionName, r.Id FROM tabCountry c, tabRegion r WHERE c.Id = r.countryId";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $cheader = $row['countryName']; if (strcmp($country,$cheader) !=0){ $country = $row['countryName']; echo <<<HTML <br> <div class="homebar2"><h1>$cheader</h1></div> <div class="country"> <img src="../thumb/phpThumb.php?src=../images/country_{$row['countryImage']}&w=100&h=100&zc=1" alt="Latest Deals"> </div> HTML; }echo <<<HTML <div class="countrycontent"><a href="index.php?Id=16&id={$row['Id']}">{$row['regionName']}</a><br></div>HTML;} ?><?php } ?>[/code]and then it goes through to the hotels page, with this code ...[code]<?phpmysql_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\">"; if ($row['hotelRating'] == 3){$star = "../images/star3.jpg";}else if ($row['hotelRating'] == 4){$star = "../images/star4.jpg";}else if ($row['hotelRating'] == 5){$star = "../images/star5.jpg";}// List the hotelsecho "<div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".$description."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>\n";}mysql_free_result($rsHotels);?>[/code]this is all working fine, for hotelsbut now the client has asked that if this can be done for 3 different types:Hotels ( which is done )GolfVillasso I added the hoteltype to the hotels table in the SQL as you can see, and what I was thinking of is that, when they are entering all this in the backend of the site, they ca nselect th hotel type, and it will go to that page e.g if it is Villa then go to Id=19any suggestions on how I can do this?i tried using case, but all the records just follow the first hotelId, this si the coase code i used:[code]switch($row_rsAccomodation['hotelType']){ case 'Hotel': if($row_rsPages['Id']== "15") include "pages/country.php"; break; case 'Villa': if($row_rsPages['Id']== "3") include "pages/country_villa.php"; break; case 'Golf': if($row_rsPages['Id']== "2") include "pages/country_golf.php"; break; default: break; }?>[/code]any suggestions please... Link to comment Share on other sites More sharing options...
ltoto Posted October 24, 2006 Author Share Posted October 24, 2006 anyone got ay advice.... Link to comment Share on other sites More sharing options...
Barand Posted October 24, 2006 Share Posted October 24, 2006 I am experiencing deja vu with this post. Didn't I see this question herehttp://www.phpfreaks.com/forums/index.php/topic,112113.msg454976.html#msg454976Forum rules : Don't double post. Closed. Link to comment Share on other sites More sharing options...
Recommended Posts