Shadycuz Posted November 29, 2006 Share Posted November 29, 2006 Hey guys,My name is Levi and I'm a High School student. My knowledge with PHP and mysql is limited. I Already have PHP and mysql Installed and working fine. I use phpmyadmin to administrate the database. I have every thing set up fine but I would like some assistance on setting up my tables. Recenty I have undergone the project of setting up a fake realtors website for a school project.Back the the subject, the problem I'm having is adding a Field to my table that will have the houses being sold in. I want to have a field where I can set a price range like 40,000-60,000 dollar houses and ect. I haven't been able to figure out which type it is like int or enum. I also was wondering if I needed a different table for each price bracket. Remember this will all need to be search able from a php form. For example if you wanted to search for a house by price range you would select the range from a drop down box on the search page, or by location or number of bed rooms ect. ect. I hope I explained this clearly and you can help me finish my database so i can start on the php. Thx for taking the time to read this. I will check back offten for the deadline for this is just a few months away. Sincerely,Levi Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/ Share on other sites More sharing options...
fenway Posted November 29, 2006 Share Posted November 29, 2006 You should have another table with prices range (low, high, as ints, probably), and then link a FK to this table from your houses table. Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/#findComment-132107 Share on other sites More sharing options...
Shadycuz Posted November 29, 2006 Author Share Posted November 29, 2006 Hi,And thx for the reply, but what I want is a price range like 30,000 to 40,000. Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/#findComment-132126 Share on other sites More sharing options...
matto Posted December 1, 2006 Share Posted December 1, 2006 why don't you use 2 fields, one to store the minimum price and the other to store the maximum price (both with type of int) Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/#findComment-133146 Share on other sites More sharing options...
jsladek Posted December 1, 2006 Share Posted December 1, 2006 You should only have 1 feild. The price of the house. If the user wants to see all houses in a range you use SQL to select those houses-John Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/#findComment-133164 Share on other sites More sharing options...
fenway Posted December 3, 2006 Share Posted December 3, 2006 [quote author=jsladek link=topic=116713.msg476726#msg476726 date=1164946157]You should only have 1 feild. The price of the house. If the user wants to see all houses in a range you use SQL to select those houses-John[/quote]Of course... I actually thought the poster wanted the houses to have a high & low price. Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/#findComment-134475 Share on other sites More sharing options...
Shadycuz Posted December 11, 2006 Author Share Posted December 11, 2006 [quote author=jsladek link=topic=116713.msg476726#msg476726 date=1164946157]You should only have 1 feild. The price of the house. If the user wants to see all houses in a range you use SQL to select those houses-John[/quote]Thanks for the reply but how would I add a search in php code? I need this so the user end can search my database. I would like for their to be a drop down menue that has choices like 30,000-40,000 and 50,000-60,000 ect. I will try to add one field on my own and see if i can get the prices to work. But any help with the php search is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/#findComment-138994 Share on other sites More sharing options...
jsladek Posted December 11, 2006 Share Posted December 11, 2006 take http://realtor.com/ for example. They have two selection boxes one for highprice and one for low price. Looks like they have some Javascript verifing the feilds too... anyhow once you have the two prices you would create your SQL based on them.You will have to work on the SQL to get it right but I would expect it to look like one of the following might work. The first one, I was using a similar SQL but with dates not house prices but I think it should be ok.[code]$sql_house_data="SELECT * FROM house_data WHERE house_price between '$lowprice' and '$highprice'";[/code]Or maybe this one if that is not working..[code]$sql_house_data="SELECT * FROM user_data WHERE house_price >= '$lowprice' AND house_price <= '$highprice'";[/code]-John Quote Link to comment https://forums.phpfreaks.com/topic/28859-mysql-table-help/#findComment-139358 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.