HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 I'm aware of that, but you need to show me what the SQL code is that's getting the recordset for that drop down.Based on what you've said in the past, I'd imagine it's something like...[code]<select name="selectCountry" id="selectCountry" title="<?php echo $row_rsAccomedit['hotelCountry']; ?>"><?php do {?><option value="<?php echo $row_rsRegion['Id']?>"<?php if (!(strcmp($row_rsRegion['Id'], $row_rsAccomedit['regionId']))) {echo "SELECTED";} ?>><?php echo $row_rsRegion['regionName']?></option><?php } while ($row_rsRegion = mysql_fetch_assoc($rsRegion)); $rows = mysql_num_rows($rsRegion); if($rows > 0) { mysql_data_seek($rsRegion, 0); $row_rsRegion = mysql_fetch_assoc($rsRegion); }?></select>[/code]Huggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 right so moving on to the front end now, so the code is like this at the moment[code]<?phpif($row_rsPages['Id']== "15" ){$row_rsCountry_Q = mysql_query("SELECT * FROM tabCountry ORDER BY 'countryName' ") or die(mysql_error());while($row_rsCountry = mysql_fetch_array($row_rsCountry_Q)){echo '<h2>'. $row_rsCountry['countryName'].'</h2>';}$row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'regionName' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ") or die(mysql_error());while($row_rsRegion = mysql_fetch_array($row_rsRegion_Q)){echo '<br />' . $row_rsRegion['regionName'] . '<br />';}}?>[/code]what changes will need to be made to this in order for everything to work Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 Change this row:[code]$row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'regionName' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ") or die(mysql_error());[/code]To: [code]$row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'countryId' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ") or die(mysql_error());[/code]RegardsHuggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 ok i have done that, but it still doesnt seem to be showing the regions from the country, just the list of countrys still, Im guessing i have a mistake somewhere along the line, any ideas where icoul dof made it Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 Are you able to post the entire code from that page, I'd like to take a look at it if possible?Huggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 i think there are many errors on this page which i have to go through and correct, which i normally go through when the page is complete, so this is the last stage of the page[code]<?php$currentPage = $_SERVER["PHP_SELF"];$colname_rsPages = "1";if (isset($_GET['Id'])) {$colname_rsPages = (get_magic_quotes_gpc()) ? $_GET['Id'] : addslashes($_GET['Id']);}mysql_select_db($database_conTotal, $conTotal);$query_rsPages = sprintf("SELECT * FROM tabPages WHERE Id = %s", $colname_rsPages);$rsPages = mysql_query($query_rsPages, $conTotal) or die(mysql_error());$row_rsPages = mysql_fetch_assoc($rsPages);$totalRows_rsPages = mysql_num_rows($rsPages);$maxRows_rsDeals = 4;$pageNum_rsDeals = 0;if (isset($_GET['pageNum_rsDeals'])) {$pageNum_rsDeals = $_GET['pageNum_rsDeals'];}$startRow_rsDeals = $pageNum_rsDeals * $maxRows_rsDeals;mysql_select_db($database_conTotal, $conTotal);$query_rsDeals = "SELECT * FROM tabLatestDeals WHERE Id = Id ORDER BY Id DESC";$query_limit_rsDeals = sprintf("%s LIMIT %d, %d", $query_rsDeals, $startRow_rsDeals, $maxRows_rsDeals);$rsDeals = mysql_query($query_limit_rsDeals, $conTotal) or die(mysql_error());$row_rsDeals = mysql_fetch_assoc($rsDeals);if (isset($_GET['totalRows_rsDeals'])) {$totalRows_rsDeals = $_GET['totalRows_rsDeals'];} else {$all_rsDeals = mysql_query($query_rsDeals);$totalRows_rsDeals = mysql_num_rows($all_rsDeals);}$totalPages_rsDeals = ceil($totalRows_rsDeals/$maxRows_rsDeals)-1;$colname_rsForm = "1";if (isset($_GET['Id'])) {$colname_rsForm = (get_magic_quotes_gpc()) ? $_GET['Id'] : addslashes($_GET['Id']);}mysql_select_db($database_conTotal, $conTotal);$query_rsForm = sprintf("SELECT * FROM tabForm WHERE Id = %s", $colname_rsForm);$rsForm = mysql_query($query_rsForm, $conTotal) or die(mysql_error());$row_rsForm = mysql_fetch_assoc($rsForm);$totalRows_rsForm = mysql_num_rows($rsForm);mysql_select_db($database_conTotal, $conTotal);$query_rsGolf = "SELECT * FROM tabPages WHERE Id = 2";$rsGolf = mysql_query($query_rsGolf, $conTotal) or die(mysql_error());$row_rsGolf = mysql_fetch_assoc($rsGolf);$totalRows_rsGolf = mysql_num_rows($rsGolf);mysql_select_db($database_conTotal, $conTotal);$query_rsTour = "SELECT * FROM tabPages WHERE Id = 13";$rsTour = mysql_query($query_rsTour, $conTotal) or die(mysql_error());$row_rsTour = mysql_fetch_assoc($rsTour);$totalRows_rsTour = mysql_num_rows($rsTour);mysql_select_db($database_conTotal, $conTotal);$query_rsCustom = "SELECT * FROM tabPages WHERE Id = 14";$rsCustom = mysql_query($query_rsCustom, $conTotal) or die(mysql_error());$row_rsCustom = mysql_fetch_assoc($rsCustom);$totalRows_rsCustom = mysql_num_rows($rsCustom);mysql_select_db($database_conTotal, $conTotal);$query_rsVillas = "SELECT * FROM tabPages WHERE Id = 3";$rsVillas = mysql_query($query_rsVillas, $conTotal) or die(mysql_error());$row_rsVillas = mysql_fetch_assoc($rsVillas);$totalRows_rsVillas = mysql_num_rows($rsVillas);$maxRows_rsHotel = 10;$pageNum_rsHotel = 0;if (isset($_GET['pageNum_rsHotel'])) {$pageNum_rsHotel = $_GET['pageNum_rsHotel'];}$startRow_rsHotel = $pageNum_rsHotel * $maxRows_rsHotel;mysql_select_db($database_conTotal, $conTotal);$query_rsHotel = "SELECT * FROM tabHotel";$query_limit_rsHotel = sprintf("%s LIMIT %d, %d", $query_rsHotel, $startRow_rsHotel, $maxRows_rsHotel);$rsHotel = mysql_query($query_limit_rsHotel, $conTotal) or die(mysql_error());$row_rsHotel = mysql_fetch_assoc($rsHotel);if (isset($_GET['totalRows_rsHotel'])) {$totalRows_rsHotel = $_GET['totalRows_rsHotel'];} else {$all_rsHotel = mysql_query($query_rsHotel);$totalRows_rsHotel = mysql_num_rows($all_rsHotel);}$totalPages_rsHotel = ceil($totalRows_rsHotel/$maxRows_rsHotel)-1;$maxRows_rsCountry = 10;$pageNum_rsCountry = 0;if (isset($_GET['pageNum_rsCountry'])) { $pageNum_rsCountry = $_GET['pageNum_rsCountry'];}$startRow_rsCountry = $pageNum_rsCountry * $maxRows_rsCountry;$colname_rsCountry = "1";if (isset($_GET['countryName'])) { $colname_rsCountry = (get_magic_quotes_gpc()) ? $_GET['countryName'] : addslashes($_GET['countryName']);}mysql_select_db($database_conTotal, $conTotal);$query_rsCountry = sprintf("SELECT * FROM tabCountry WHERE countryName = '%s'", $colname_rsCountry);$query_limit_rsCountry = sprintf("%s LIMIT %d, %d", $query_rsCountry, $startRow_rsCountry, $maxRows_rsCountry);$rsCountry = mysql_query($query_limit_rsCountry, $conTotal) or die(mysql_error());$row_rsCountry = mysql_fetch_assoc($rsCountry);if (isset($_GET['totalRows_rsCountry'])) { $totalRows_rsCountry = $_GET['totalRows_rsCountry'];} else { $all_rsCountry = mysql_query($query_rsCountry); $totalRows_rsCountry = mysql_num_rows($all_rsCountry);}$totalPages_rsCountry = ceil($totalRows_rsCountry/$maxRows_rsCountry)-1;mysql_select_db($database_conTotal, $conTotal);$query_rsRegion = "SELECT * FROM tabRegion";$rsRegion = mysql_query($query_rsRegion, $conTotal) or die(mysql_error());$row_rsRegion = mysql_fetch_assoc($rsRegion);$totalRows_rsRegion = mysql_num_rows($rsRegion);mysql_select_db($database_conTotal, $conTotal);$query_rsRegion = "SELECT * FROM tabRegion";$rsRegion = mysql_query($query_rsRegion, $conTotal) or die(mysql_error());$row_rsRegion = mysql_fetch_assoc($rsRegion);$totalRows_rsRegion = mysql_num_rows($rsRegion);?><?if($row_rsPages['Id'] == "1" ){echo ?> <div id="homebg"> <? } ?> <h2><?php echo $row_rsPages['pagesTitle']; ?></h2><?php echo $row_rsPages['pagesContent']; ?><?if($row_rsPages['Id'] == "1" ){echo ?> </div><? } ?><?phpif(@$_GET['Id']== "12") { ?><?php do { ?><div class="Dealsbar2"><h1><?php echo $row_rsDeals['dealsTitle']; ?></h1></div><div class="Deals2"><img src="/images/deals_<?php echo $row_rsDeals['dealsImage']; ?>" alt="Latest Deals"><br><div class="contentbox"> <?php echo $row_rsDeals['dealsContent']; ?><br><br></div></div><div class="Deals2"><div class="dealsbox"> <div class="Deals2date"> Date: <?php echo $row_rsDeals['dealsDate']; ?></div></div><div class="Deals2price"> Price:£<?php echo $row_rsDeals['dealsPrice']; ?></div></div><?php } while ($row_rsDeals = mysql_fetch_assoc($rsDeals)); ?><?php } ?><?phpif($row_rsPages['Id']== "15" ){$row_rsCountry_Q = mysql_query("SELECT * FROM tabCountry ORDER BY 'countryName' ") or die(mysql_error());while($row_rsCountry = mysql_fetch_array($row_rsCountry_Q)){echo '<h2>'. $row_rsCountry['countryName'].'</h2>';}$row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'countryId' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ") or die(mysql_error());while($row_rsRegion = mysql_fetch_array($row_rsRegion_Q)){echo '<br />' . $row_rsRegion['regionName'] . '<br />';}}?><?phpif($row_rsPages['Id']== "1") { ?><div class="homebar2"><h1>Golf Holidays </h1></div><p><?phpfunction cutit ($var, $max){return (strlen( $var ) > $max) ? substr($var, 0, $max).'...' : $var;}echo cutit ($row_rsGolf['pagesContent'], 250);?></p><div class="moreinfo"> <a href="index.php?Id=2"><img src="../images/moreinfo.jpg" alt="moreinfo" width="75" height="18" border="0"></a></div><div class="homebar2"><h1>Tour Packages </h1> </div><p><?php echo strip_tags(cutit($row_rsTour['pagesContent'], 250));?></p><div class="moreinfo"> <a href="index.php?Id=13"><img src="../images/moreinfo.jpg" alt="moreinfo" width="75" height="18" border="0"></a></div><div class="homebar2"><h1>Custom Holidays</h1></div><p><?php echo strip_tags(cutit($row_rsCustom['pagesContent'], 250));?></p><div class="moreinfo"> <a href="index.php?Id=14"><img src="../images/moreinfo.jpg" alt="moreinfo" width="75" height="18" border="0"></a></div><div class="homebar2"><h1>Villa Property </h1></div><p><?php echo strip_tags(cutit($row_rsVillas['pagesContent'], 250));?> </p><div class="moreinfo"> <a href="index.php?Id=3"><img src="../images/moreinfo.jpg" alt="moreinfo" width="75" height="18" border="0"></a></div><?php } ?><?phpmysql_free_result($rsPages);mysql_free_result($rsDeals);mysql_free_result($rsForm);mysql_free_result($rsGolf);mysql_free_result($rsTour);mysql_free_result($rsCustom);mysql_free_result($rsVillas);mysql_free_result($rsHotel);mysql_free_result($rsCountry);mysql_free_result($rsRegion);?>[/code]the next words i am guessing you will say is, the code is a mess :(, but i think most of the mess is just the stuff dreamweaver does Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 It is quite messy, but if you're new it's understandable, no doubt when I write my first proper php script it will be the same. However, having said that, it looks as though the code itself is fine.I'm assuming this is a front page, or something similar?Do you have a URL where this is live, or are you testing locally? If a live URL, can you provide it?Huggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 this is the page where the pages are, if that makes sense.It is being tested on my companies local server at the mo, but maybe i could upload it to my site Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 this is what it is on at the momenthttp://www.ryanbenbow.co.uk/travel/index.php?Id=15there will be errors with pictures cos i just put it on here Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 OK, there's no drop downs on that page at all...Huggie Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 oh ok, my bad. I'm looking again now.Rich Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 oops i also just deleted my post , because iwas gonna post again so i didnt double post,ok, hopefully the problem can be sorted out with your help, i am hoping this part of the site can be done for around 530 pm today :) Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 ok, try replacing all of your code that gets the countries and regions with this:[code]<?php// Your select to get all the data, I've tried to remember your column/table data$sql="SELECT c.countryName, r.regionName, r.regionID FROM tblCountry c, tblRegion r WHERE c.countryID = r.countryID";$result = mysql_query($sql);$country = "null";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $cheader = $row['countryName']; if (is_null($country) || strcmp($country,$cheader) !=0){ $country = $row['countryName']; echo <<<HTML <br> <h2>$country</h2>HTML; }echo <<<HTML <a href="hotels.php?regionid=$row[regionID]">$row[regionName]</a><br>HTML;}?>[/code]See example here: http://www.dizzie.co.uk/php/pages2.phpRegardsHuggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 i got this error:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resourcefrom this line [code]while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){[/code] Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 ok, add error checking then...[code]<?php// Your select to get all the data, I've tried to remember your column/table data$sql="SELECT c.countryName, r.regionName, r.regionID FROM tblCountry c, tblRegion r WHERE c.countryID = 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 (is_null($country) || strcmp($country,$cheader) !=0){ $country = $row['countryName']; echo <<<HTML <br> <h2>$country</h2>HTML; }echo <<<HTML <a href="hotels.php?regionid=$row[regionID]">$row[regionName]</a><br>HTML;}?>[/code]RegardsHuggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 what is the r. bit for, do i keep that or just replace it Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 They're table aliases... Because we're joining to another table, it's shorter than specifying the whole table name.Rich Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 wahay, it is working, thanks a lot man, i think i understand most of it now aswell which is good, so now i just put the code on the hotel page which you gave before and this section s complete Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 I hope so ;)Well done for persevering.Huggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 i dont seem to be able to find the code now though, did it get deleted, or am i just being blind? Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 Did you have any code for a hotel page yet? I don't think I've seen any...It might be an idea to mork this thread as solved and then start a new one with any hotel related pages, as this is getting quite long now.Huggie Quote Link to comment Share on other sites More sharing options...
ltoto Posted September 14, 2006 Author Share Posted September 14, 2006 right ok, will do, maybe i shall see you there ;D 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.