ltoto Posted October 20, 2006 Share Posted October 20, 2006 Ok so as i said in another thread a thought the probelm was with this:[code]<?phpswitch($row_rsHotel['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]so whats happening is there are 3 hotel types, Hotel, Villa, and Golf, and when one of these is selected it will go to a new page.whats happening is that, whenever i change the hotel type in the first id field in the SQL, it changes all of the hotels to this, so they all follow the first Id, which i do not what to happen, any suggestions as to why this is happening..... Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 huh? where does SQL come into play here? your code is simply a switch statement (apparently based off a SQL query by your question). it sounds like your update query may not be properly filtering your records, and you're updating all records instead of just the one you're after.why don't you share with us your method of updating your record, and let's figure out why they're all changing. Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 20, 2006 Author Share Posted October 20, 2006 its updates in the backend with the admin panel, this is the update:[code]if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE tabHotel SET hotelName=%s, hotelDescription=%s, hotelRating=%s, regionId=%s, hotelType=%s WHERE Id=%s", GetSQLValueString($_POST['txtName'], "text"), GetSQLValueString($_POST['txtDescription'], "text"), GetSQLValueString($_POST['selectRating'], "text"), GetSQLValueString($_POST['selectCountry'], "int"), GetSQLValueString($_POST['selectType'], "text"), GetSQLValueString($_POST['hidId'], "int"));[/code] Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 20, 2006 Author Share Posted October 20, 2006 any ideas at all as to why this is happening................. Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 well, it appears that your update statement is constructed properly. have you checked the data in your records after an update? is the data itself updated in every row, or is it the code displaying it that is causing the problem? Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 20, 2006 Author Share Posted October 20, 2006 everything is updating fine, it just seems to be taking everything with the first Id, but not actually changing the other ones, to get it on everypage i could do this[code]<? if(@$_GET['Id']=="15") include 'country.php'; else if(@$_GET['Id']=="2") include 'country_villa.php'; else if(@$_GET['Id']=="3") include 'country_golf.php';?><?phpswitch($row_rsHotel['hotelType']){ case 'Hotel': if(@$_GET['Id']== "15") break; case 'Villa': if(@$_GET['Id']== "2"); break; case 'Golf': if(@$_GET['Id']== "3"); break; default: break; }?>[/code]but it still wouldnt solve the problem, but it would get it on the right pages Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 ok, maybe i should back up a step: how is your $row_rsHotel array being populated? that's what you're running your switch on. can you explain what it is your switch is supposed to do? are you displaying details for each hotel with it? you are checking for two variables to be true in your switch statement as it stands in your first post: the only way "pages/country.php" is going to be included is if 1) $row_rsHotel['hotelType'] == 'Hotel' AND 2) $_GET['Id'] == 15.i'm afraid you're going to have to really try to explain what you're doing with those variables and how they're being populated, because, as it is, if your update is working right, we've got to know more than just [i]it's not working[/i]. Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 20, 2006 Author Share Posted October 20, 2006 ok so this is what is happeningeverthing you have said si correctthere are 3 hotel types, Golf, hotel, and Villaeach has a different Id page e.gGolf Id = 3Hotel Id = 15Villa Id= 2when they go on a page, e.g the hotels page, a list of coutrys will come up ( these countrys are added in the Admin side of the website )and within the country, a list of regions show that are with the country, so it wil appaer like this for example:SPAIN :Murica, Madrid the code used to do this is [code]<?php $sql="SELECT tabCountry.countryName, tabCountry.countryImage, tabRegion.regionName, tabRegion.Id FROM tabCountry , tabRegion WHERE tabCountry.Id = tabRegion.countryId";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $name = $row['countryName']; if (strcmp($country,$name) !=0){ $country = $row['countryName']; echo <<<HTML <br> <div class="homebar2"><h1>$name</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;} ?>[/code]this code is on the country.php page, and is the same on country_villa and country_hotel apart from the link at the bottom where i have changed the Id to o to the right place.When i region is clicked on, it goes to a new page, with the list of hotels within that regiondone with this code:[code]<?php$colname_rsHotels = "1";if (isset($_GET['Id'])) { $colname_rsHotels = (get_magic_quotes_gpc()) ? $_GET['Id'] : addslashes($_GET['Id']);}mysql_select_db($database_conTotal, $conTotal);$query_rsHotels = sprintf("SELECT * FROM tabHotel WHERE Id = %s", $colname_rsHotels);$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]so what happens at the moment is that the villa, golf and hotel, hotels appear on each page, but what i am tryin to do is get it that on the hotel page, it just hsows the hotel, hotelson the villa page the villa ones, and the golf page, the golf ones..... Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 ah, ok. so, you're wanting to have sort of a [i]filter[/i] to show all of one type of hotel? it sounds like you just need to add another filter to your query based on what was selected to filter by. i would recommend doing this with a single [b]filter[/b] page instead of separate pages for each. this way, you avoid a ton of repetative code. something like this should work (you'll probably have to adjust it to suit your database):[code]<?php// default your filter page to show hotels$filter = isset($_GET['filter']) ? $_GET['filter'] : "Hotel";switch($filter) { case "Villa": $where = "hotelType = 'Villa'"; break; case "Golf": $where = "hotelType = 'Golf'"; break; default: $where = "hotelType = 'Hotel'";}$sql = mysql_query("SELECT * FROM hotels WHERE $where");// now display your results reflecting the filter?>[/code]and to set up your filter, all you have to do is set up some links:[code]<a href="?filter=Hotel">Show only Hotels</a><a href="?filter=Villa">Show only Villas</a><a href="?filter=Golf">Show only Golf</a>[/code]hope this helps! Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 20, 2006 Author Share Posted October 20, 2006 the reason i have different pages though, is because the client asked for a hotel page, a villas page, and a golf page Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 ok, well, just use the same logic as i showed above, but then set your SQL statement at the top of each page, and then make your links point to the separate pages directly. Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 20, 2006 Author Share Posted October 20, 2006 so now i need to add something to this code i guess because its now showing each hotel on each section[code]<?php $sql="SELECT tabCountry.countryName, tabCountry.countryImage, tabRegion.regionName, tabRegion.Id FROM tabCountry , tabRegion WHERE tabCountry.Id = tabRegion.countryId";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $name = $row['countryName']; if (strcmp($country,$name) !=0){ $country = $row['countryName']; echo <<<HTML <br> <div class="homebar2"><h1>$name</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;} ?>[/code] Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 right i tried the filter thing but couldnt get it to work, so i am trying this[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]but it just follows the first Id still Quote Link to comment Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 [code]<?phpmysql_select_db($database_conTotal, $conTotal);$query_rsHotellist = "SELECT * FROM tabHotel WHERE hotelType = 'Hotel'";$rsHotellist = mysql_query($query_rsHotellist, $conTotal) or die(mysql_error());$row_rsHotellist = mysql_fetch_assoc($rsHotellist);$totalRows_rsHotellist = mysql_num_rows($rsHotellist); $sql="SELECT tabCountry.countryName, tabCountry.countryImage, tabRegion.regionName, tabRegion.Id FROM tabCountry , tabRegion WHERE tabCountry.Id = tabRegion.countryId";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $name = $row['countryName']; if (strcmp($country,$name) !=0){ $country = $row['countryName']; echo <<<HTML <br> <div class="homebar2"><h1>$name</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']}&hotelType='Hotel'">{$row['regionName']}&</a><br></div>HTML;} mysql_free_result($rsHotellist);?>,[/code]do i put the case code on this page, I also have one for Gold and hotel with the same code, but the type at the top changes and the link at the bottom 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.