Jump to content


Photo

SOLVED 2 Repeat Regions


  • Please log in to reply
71 replies to this topic

#21 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 10:14 AM

this error:

Table 'totaltravel.Id' doesn't exist

i think i understand, where it says from Id, i must put the name of the tabe so

tabCountry for example is the name of the country table

EDIT: it seems to be error free now, but nothing is actually showing on the page

#22 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 10:42 AM

i made a mistake with the Deals recordset, so the code now is

<?php

if($row_rsPages['Id']== "15")
{
$row_rsCountry_Q = mysql_query("SELECT * FROM tabCountry WHERE 'Id' 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 />';
}
}
?>

i cant see why it is not now showing on the page, so maybe someelse can see

#23 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 11:27 AM

mysql_query("SELECT * FROM tabCountry WHERE 'Id' ORDER BY 'countryName' ") or die(mysql_error());

I'm assuming that with this piece of code that you want to select every country?  If so, you can drop the WHERE 'id' as it's not actually doing anything unless you specify something after it, such as WHERE id = '$num'

We seem to be going around the houses here, to help us to help you, can you provide us with your table names and a list of the columns in those tables?

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#24 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 12:07 PM

The country table is:

tabCountry:

id
countryName



and the Region Table is

tabRegion:

id
regionName


there is also a table after this , so when they click on region, the list of hotels on that region appear, on a new page:

tabHotel:

id
hotelName
hotelCountry
hotelRegion
hotelImage
hotelDescription
hotelRating

in the CMS to this, there are drop down menus for The COuntry and Region,  in the hotel section.

I hope this helps

#25 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 12:17 PM

OK, now it's starting to make sense, did you design the tables or did you get this script from somewhere as a 'pre-built'?

I think the database design is slightly out.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#26 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 12:19 PM

i designed the tables myself

Would i need to add something to one of the region or country tables then i assume

#27 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 01:00 PM

<?php

if($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 />';
}
}
?>

right now this is the code, which shows the Countrys Fine now, but not the regions, i am assuming i must add something to the region table , so that the same regions dont list in every country, but they only show in the country that they are from.

alothough i have been looking and am a little confused of what needs adding to the table.

hope this makes sense

#28 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 01:06 PM

Id say you needed them as follows:

tabCountry - countryID, countryName
tabRegion - regionID, countryID, regionName
tabHotel - hotelID, regionID, hotelName, hotelImage, hotelDescription, hotelRating


This way you can cascade down.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#29 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 01:08 PM

so basically just add the country name to the tabRegion, and set the drop down menu up in the database, so i can choose the country for the region, and then would the code work in the front end or would it need changing

#30 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 01:13 PM

Your code in the front-end would possibly need changing too, but with the tables setup as they are, you can get the following:

All Countries,
All Regions in a specific country,
All Hotels in a specific country,
All Regions,
All Hotels in a specific region,
All Hotels.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#31 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 01:17 PM

so just to clarify, without changing the tables, I could do that with what i have got at the moment, which is what I am looking to do?

if so, I am assuming this bit needs changin in the code:

$row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'regionName' = '".$row_rsCountry['Id']."' ORDER BY 'countryName' ") or die(mysql_error());
while($row_rsRegion = mysql_fetch_array($row_rsRegion_Q))
{
echo '<br />' . $row_rsRegion['regionName'] . '<br />';

again rich thanks for helping, I am just getting confised and struggling at the moment because this is the first time i have done something like this, and i am trying to get it finished asap, you have been a great help so far, as has everyone else who has replied...

#32 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 01:36 PM

so just to clarify, without changing the tables, I could do that with what i have got at the moment


No, as you have it now, with your current database structure, you have no way of linking the region to the country.  This means if you have three countries in your country list, and want to display the regions based on one particular country you can't, and this is exactly your problem.

SELECT * FROM tabRegion WHERE regionName = '".$row_rsCountry['Id']."'.

Your code references a column that doesn't make sense I've put dummy examples in to illustrate...
Select all columns from the table tabRegion where the region name (London) is equal to $row_rsCountry['Id'] (5)

Your regionName column is going to be a logical name (I'm assuming) but you're trying to link it to countryID which is going to be a number.  They're never going to match.

Can you see what I'm getting at here?

If you had a countryID column in tblRegion then you'd almost be there, but the above would need to look like this:

SELECT * FROM tabRegion WHERE countryID = '".$row_rsCountry['Id']."'.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#33 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 01:38 PM

ok , so i will now add into the tabRegion somewhere to add country name, then do the dropdown menu in the backend, and go from there

#34 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 01:41 PM

Not country name, country ID.  Look at my previous structure....

tabCountry - countryID, countryName
tabRegion - regionID, countryID, regionName
tabHotel - hotelID, regionID, hotelName, hotelImage, hotelDescription, hotelRating


Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#35 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 03:08 PM

quick question, with it being the ID , in the backend when they want to choose i hotel, would it just list the Id number instead,  though I am sure i did it before with the Id number and the name next to it

#36 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 03:14 PM

No, you can set it up so that it shows the hotel name... Here's an example:

$sql = "SELECT hotelName FROM tblHotel where regionID = $row_rsRegion['id']";

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#37 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 03:20 PM

http://212.161.124.21/hotellist.asp

i should of posted this at the start to help you, but this is how I am planning on it coming out when it is finished, something like this

#38 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 03:24 PM

Yes, that's no problem, it's perfectly achievable with what you have.

I'm not sure what you're doing with the back-end, but yes, the front end can do that without issue.

Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#39 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 13 September 2006 - 03:30 PM

i will explain briefly about the backend to help you understand, hope it helps

basically, firstly the customer will be adding the Country Name, which is done.

After this the will go on to a separte section where they can add a region, which at the moment they can only add the region( but the way the tables are now I am guessing they can add the countrys, which will appear in a dynamic dropdown list, after they have sumbitted this, they will the go onto the hotel adding part where they can select the country the hotel is from , from a dynamic dropdown list, and they can do the same when slecting a region.

they will also add a hotel picture, description and hotel rating.

Hope this helps you understnad what i am tryin to do in the backend more

#40 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 03:44 PM

Yes, it's all possible.

addhotel.php - They can add in new hotels, this page will contain the dynamically generated drop down menus for both country and region, along with the additional fields you're after (Image, description etc).  If the hotel's in a new region they can click a text link next to the region drop down to take them to a new page to add a region.

addregion.php - Here they can add a new region by typing its name in a text box and selecting the country from a dynamically generated drop down.  If the country doesn't exist then they can click the text link next to the country drop down to take them to a new page to add a country.

addcountry.php - Here they can add a new country in a text box.


It's important to note that they must assign the hotel to a region and the region to the country.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users