Web Hosting Talk







View Full Version : [PHP/MySQL] How To?


JustinSmall
02-28-2008, 02:18 PM
Ok, I have a Properties table in my database. And in the properties there are bedrooms.

Now if the user selects 21 from the drop down menu (so 21 bedrooms).

Now I want him to be able to tell me how many of 6 different beds are in "EACH" bedroom. How could I do this via mysql without having 99 different rows for each in the table on mysql?

ktshannon
02-28-2008, 02:23 PM
http://www.freewebmasterhelp.com/tutorials/phpmysql

suggest reading up on php/mysql more ;)

JustinSmall
02-28-2008, 02:36 PM
No no no, I'm mysql friendly lol

I already have 200 some rows in the database, I don't need 99x5 more.

jimpoz
02-28-2008, 03:45 PM
Sounds like you would need to have bedrooms in one table, beds in a second, and a linking table with bedroomID and bedID in a third, and then join them together. The linking table may have a column with quantity that you can SUM().

JustinSmall
02-28-2008, 04:05 PM
So if I had say 88 bedrooms. It would create 88 new bedrooms in the second database, all with the same propertyID. (I would go by property Id's)

And then I would only need to create the bedroom with however many bed types I have in the database.

Sounds like it could work...

zacharooni
02-28-2008, 05:17 PM
SELECT COUNT(*) FROM roomProps WHERE bedType="Queen" AND othercondition="" AND othercondition="";