ltoto Posted October 19, 2006 Share Posted October 19, 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? Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 19, 2006 Author Share Posted October 19, 2006 do i need to show the insert for the first code, the way I was gonna do this was with Hidden fields e.ghidAction value =hotel then do that for golf and villas...... if this makes sense Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.