ltoto Posted October 25, 2006 Share Posted October 25, 2006 right this is what i need to do, i have a hotel page, a golf page, and a villa page, when i click on the villa page it shows the list of villas, when i go on the hotel page, it shows the list of hotels, and when i go on the golf page it shows the list of golf hotels.in the sql table i have a feild called hotelType, where in the backend they can select i f the hotel type is either Villa, Golf or Hotelany suggestions as to how to do this please? Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/ Share on other sites More sharing options...
Orio Posted October 25, 2006 Share Posted October 25, 2006 On the hotel page:"SELECT * FROM Hotel_Table WHERE hotelType='Hotel'"On the villa page:"SELECT * FROM Hotel_Table WHERE hotelType='Villa'"On the Golf page:"SELECT * FROM Hotel_Table WHERE hotelType='Golf'"Orio. Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114212 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 Itoto,Am I to assume from this that you're starting again from scratch? Trying to move away from your single index.phpRegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114214 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 well the customer has changed what they wanted[code]?php$colname_rsHotels = "1";if (isset($_GET['hotelId'])) { $colname_rsHotels = (get_magic_quotes_gpc()) ? $_GET['hotelId'] : addslashes($_GET['hotelId']);}mysql_select_db($database_conTotal, $conTotal);$query_rsHotels = sprintf("SELECT * FROM tabHotel WHERE hotelId = %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"; } echo "<div class=\"homebar2\"><h1>$name</h1></div>\n"; echo "<div class=\"hotel\">$image</div>\n"; echo "<div class=\"hotelcontent\">" .substr($description, 0, 300) . "...</div>\n"; echo "<h3>Hotel Star: <img src=\"$star\" hspace=\"2\"></h3>\n";echo "<div class=\"moreinfo\"><a href=\"index.php?Id=22&hotelId=$row[hotelId]\"><img src=\"../images/moreinfo.jpg\" alt=\"moreinfo\" width=\"75\" height=\"18\" border=\"0\"></a></div>\n";}?><? mysql_free_result($rsHotels);?>[/code]so this is my code where the hotels are displayed, and this is used for the hotel, villa, and golf pages Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114218 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={$row_rsHotellist['hotelType']}">{$row['regionName']}</a><br></div>HTML;} mysql_free_result($rsHotellist);?>[/code]this is the code to get to the hotels l ist aswell, but i have another page for villa, and golf, where I change the WHERE at the top to either golf of villa, and then at the bottom, change the Id to the right page Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114228 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 at the moment, this is the link when you select the villa hotelsindex.php?Id=20&id=1&hotelType=Villaand with golf it will beindex.php?Id=19&id=1&hotelType=Golfand with hotel:index.php?Id=16&id=1&hotelType=Hotelso on the page where all of these are displayed can i just put a get hoteltype from this part:[code]<?phpmysql_select_db($database_conTotal, $conTotal);$query_rsHotels = "SELECT * FROM tabHotel WHERE hotelType = hotelType";$rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error());$row_rsHotels = mysql_fetch_assoc($rsHotels);$totalRows_rsHotels = mysql_num_rows($rsHotels);[/code]and how would i do thisany suggestions..... Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114254 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 I'm going to be honest here. I've helped a lot on one of the other posts with getting you up and running, but I can't help but feel the architecture of this site is all wrong. For a start, the fact that you have a URL value called 'id' and another called 'Id' is very bad.In this instance, what do 'Id' and 'id' represent, I obviously know what hotelType represents.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114258 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 i no your right, but Im trying to get this bit working first, so then the site will be complete, then iwill need to tidy this up, thanks for all the help you gave me in the past, this is the last bit that needs completing now, and then i can sort out all my bad coding, so if anyone could give me a hand, that would be great...Id represents the page Id, and the small id represents the region id Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114262 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 OK, that's fair enough. Try this:[code]<?phpmysql_select_db($database_conTotal, $conTotal);$query_rsHotels = "SELECT * FROM tabHotel WHERE hotelType = {$_GET['hotelType']}";$rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error());$row_rsHotels = mysql_fetch_assoc($rsHotels);$totalRows_rsHotels = mysql_num_rows($rsHotels);?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114264 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 thanks aloti get thi error showing upUnknown column 'Hotel' in 'where clause'and obviously it changes for the golf and Villa pages Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114265 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 That's saying that the column Hotel doesn't exist in your database.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114269 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 well it is showing in the SQl table, they can choose which one they want in the Admin panel of the website, with a dropdown menu, this is the code for it[code]<select name="selectType" id="selectType"> <option value="Hotel" <?php if (!(strcmp("Hotel", $row_rsAccomedit['hotelType']))) {echo "SELECTED";} ?>>Hotel</option> <option value="Villa" <?php if (!(strcmp("Villa", $row_rsAccomedit['hotelType']))) {echo "SELECTED";} ?>>Villa</option> <option value="Golf" <?php if (!(strcmp("Golf", $row_rsAccomedit['hotelType']))) {echo "SELECTED";} ?>>Golf</option> </select>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114359 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 Yes, but the column in your database is called 'hotelType', not 'Hotel'.Look at what the error message is telling you, somewhere in you're query, you have a WHERE clause looking for a column called 'Hotel', but it doesn't exist. Check your WHERE clause columns.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114365 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 well on the pages before i have something like this:[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);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114371 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 ok, well I don't know then, are you using any dynamic column names, like this:[code=php:0]SELECT * FROM tablename WHERE $column = '$value'[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114379 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 there all just like the one above do you think it could be anything to do with this linkindex.php?Id=16&id=1&hotelType=Hotelwhen i take the hotel type bit off, it shows this errorUndefined index: hotelType Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114383 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 or this makes the error goindex.php?Id=16&id=1&hotelType='Hotel'i put ' ' around where it says hotel, but it again shows every hotel in every category, instrwad of separting them all Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114397 Share on other sites More sharing options...
ltoto Posted October 25, 2006 Author Share Posted October 25, 2006 sorry for triple post, but does anyone no which page this might be off, the error that is,i have a page called page.php, which this is all included on, and 3 pages, called country.php, country_villa.php,country_golf.php, with the code that shows the country name and region names with thie country,then the code for the hotel page which i just showed..... Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114451 Share on other sites More sharing options...
ltoto Posted October 26, 2006 Author Share Posted October 26, 2006 ok, its a new day, anyone have any ideas, when i changed the hoteltype part in the like with quotes around it it shows all of the hotels, so maybe its osmething to do with the link?any ideas Quote Link to comment https://forums.phpfreaks.com/topic/25057-sql-and-php-help-please/#findComment-114629 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.